26. whereis命令
rumenz@local:~# whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz rumenz@local:~# whereis kill kill: /bin/kill /usr/share/man/man2/kill.2.gz /usr/share/man/man1/kill.1.gz
27. service命令
在 Ubuntu 上启动 apache2 服务器
rumenz@local:~# service apache2 start * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName httpd (pid 1285) already running [ OK ]
在 Ubuntu 上停止 apache2 服务器
rumenz@local:~# service apache2 stop [ OK ]
在 Ubuntu 上停止 apache2 服务器
rumenz@local:~# service apache2 stop [ OK ]
28. alias命令
rumenz@local:~# alias l='ls -l'
检查它是否有效。
rumenz@local:~# l total 36 drwxr-xr-x 3 rumenz rumenz 4096 May 10 11:14 Binary drwxr-xr-x 3 rumenz rumenz 4096 May 21 11:21 Desktop drwxr-xr-x 2 rumenz rumenz 4096 May 21 15:23 Documents drwxr-xr-x 8 rumenz rumenz 4096 May 20 14:56 Downloads drwxr-xr-x 2 rumenz rumenz 4096 May 7 16:58 Music drwxr-xr-x 2 rumenz rumenz 4096 May 20 16:17 Pictures drwxr-xr-x 2 rumenz rumenz 4096 May 7 16:58 Public drwxr-xr-x 2 rumenz rumenz 4096 May 7 16:58 Templates drwxr-xr-x 2 rumenz rumenz 4096 May 7 16:58 Videos
rumenz@local:~# unalias l rumenz@local:~# l bash: l: command not found
29. df命令
rumenz@local:~# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 47929224 7811908 37675948 18% / none 4 0 4 0% /sys/fs/cgroup udev 1005916 4 1005912 1% /dev tmpfs 202824 816 202008 1% /run none 5120 0 5120 0% /run/lock none 1014120 628 1013492 1% /run/shm none 102400 44 102356 1% /run/user /dev/sda5 184307 79852 94727 46% /boot /dev/sda7 95989516 61104 91045676 1% /data /dev/sda8 91953192 57032 87218528 1% /personal
30. du命令
rumenz@local:~# du 8 ./Daily Pics/wp-polls/images/default_gradient 8 ./Daily Pics/wp-polls/images/default 32 ./Daily Pics/wp-polls/images 8 ./Daily Pics/wp-polls/tinymce/plugins/polls/langs 8 ./Daily Pics/wp-polls/tinymce/plugins/polls/img 28 ./Daily Pics/wp-polls/tinymce/plugins/polls 32 ./Daily Pics/wp-polls/tinymce/plugins 36 ./Daily Pics/wp-polls/tinymce 580 ./Daily Pics/wp-polls 1456 ./Daily Pics 36 ./Plugins/wordpress-author-box 16180 ./Plugins 12 ./May Articles 2013/Xtreme Download Manager 4632 ./May Articles 2013/XCache
31. rm命令
删除目录
rumenz@local:~# rm PassportApplicationForm_Main_English_V1.0 rm: cannot remove `PassportApplicationForm_Main_English_V1.0': Is a directory
rumenz@local:~# rm -rf PassportApplicationForm_Main_English_V1.0
32. echo命令
rumenz@local:~# echo "rumenz.com is a very good website" rumenz.com is a very good website
创建一个小的交互式脚本
- 创建一个文件,命名为
interactive_shell.sh
在桌面上。(记住.sh
扩展名是必须的)。 - 复制粘贴下面的脚本,完全一样,如下。
#!/bin/bash echo "Please enter your name:" read name echo "Welcome to Linux $name"
rumenz@local:~# chmod 777 interactive_shell.sh rumenz@local:~# ./interactive_shell.sh Please enter your name: Ravi Saive Welcome to Linux Ravi Saive
33. passwd命令
rumenz@local:~# passwd Changing password for rumenz. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: Password unchanged [Here was passowrd remians unchanged, i.e., new password=old password] Enter new UNIX password: ##### Retype new UNIX password:#####
34. lpr命令
rumenz@local:~# lpr -P deskjet-4620-series 1-final.pdf
35. cmp命令
文件 1.txt
rumenz@local:~# cat file1.txt Hi My name is rumenz
文件 2.txt
rumenz@local:~# cat file2.txt Hi My name is rumenz [dot] com
rumenz@local:~# cmp file1.txt file2.txt file1.txt file2.txt differ: byte 15, line 1
36. wget命令
使用 wget 下载 ffmpeg
rumenz@local:~# wget http://downloads.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2 100%[===========================================================================>] 2,75,557 67.8KB/s in 4.0s 2021-08-22 18:55:00 (67.8 KB/s) - ‘ffmpeg-php-0.6.0.tbz2’ saved [275557/275557]
37. mount命令
rumenz@local:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk ├─sda1 8:1 0 923.6G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 7.9G 0 part [SWAP] sr0 11:0 1 1024M 0 rom sdb 8:16 1 3.7G 0 disk └─sdb1 8:17 1 3.7G 0 part rumenz@local:~# su Password: rumenz@local:~# cd /dev rumenz@local:~# mkdir usb
rumenz@local:~# mount /dev/sdb1 /dev/usb
38. gcc命令
#include <stdio.h> int main() { printf("Hello world\n"); return 0; }
编译它
rumenz@local:~# gcc Hello.c
运行它
rumenz@local:~# ./a.out Hello world
这样编译
rumenz@local:~# gcc -o Hello Hello.c
rumenz@local:~# ./Hello Hello world
39. g++命令
#include <iostream> using namespace std; int main() { int a; int b; cout<<"Enter first number:\n"; cin >> a; cout <<"Enter the second number:\n"; cin>> b; cin.ignore(); int result = a + b; cout<<"Result is"<<" "<<result<<endl; cin.get(); return 0; }
编译它
rumenz@local:~# g++ Add.cpp
运行它
rumenz@local:~# ./a.out Enter first number: ... ...
这样编译
rumenz@local:~# g++ -o Add Add.cpp
运行它
rumenz@local:~# ./Add Enter first number: ... ...
40. java命令
class rumenz { public static void main(String[] arguments) { System.out.println("rumenz "); } }
使用 javac 编译
rumenz@local:~# javac rumenz.java
运行它
rumenz@local:~# java rumenz