26. 命令: whereiswhereis的作用是用来定位命令的二进制文件\资源\或者帮助页.举例来说,获得ls和kill命令 的二进制文件/资源以及帮助页: 3 | ls : /bin/ ls /usr/share/ man /man1/ ls .1.gz |
3 | kill : /bin/ kill /usr/share/ man /man2/ kill .2.gz /usr/share/ man /man1/ kill .1.gz |
注意:当需要知道二进制文件保存位置时有用.
27. 命令: service‘service‘命令控制服务的启动、停止和重启,它让你能够不重启整个系统就可以让配置生效以 开启、停止或者重启某个服务。 在Ubuntu上启动apache2 server: 3 | * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName |
4 | httpd (pid 1285) already running [ OK ] |
重启apache2 server:3 | * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName |
4 | ... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName [ OK ] |
停止apache2 server:3 | * Stopping web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName |
注意:要想使用service命令,进程的脚本必须放在‘/etc/init.d‘,并且路径必须在指定的位置。
如果要运行“service apache2 start”实际上实在执行“service /etc/init.d/apache2 start”.
28. 命令: aliasalias是一个系统自建的shell命令,允许你为名字比较长的或者经常使用的命令指定别名。
我经常用‘ls -l‘命令,它有五个字符(包括空格)。于是我为它创建了一个别名‘l'。 试试它是否能用: 04 | drwxr-xr-x 3 tecmint tecmint 4096 May 10 11:14 Binary |
05 | drwxr-xr-x 3 tecmint tecmint 4096 May 21 11:21 Desktop |
06 | drwxr-xr-x 2 tecmint tecmint 4096 May 21 15:23 Documents |
07 | drwxr-xr-x 8 tecmint tecmint 4096 May 20 14:56 Downloads |
08 | drwxr-xr-x 2 tecmint tecmint 4096 May 7 16:58 Music |
09 | drwxr-xr-x 2 tecmint tecmint 4096 May 20 16:17 Pictures |
10 | drwxr-xr-x 2 tecmint tecmint 4096 May 7 16:58 Public |
11 | drwxr-xr-x 2 tecmint tecmint 4096 May 7 16:58 Templates |
12 | drwxr-xr-x 2 tecmint tecmint 4096 May 7 16:58 Videos |
去掉’l'别名,要使用unalias命令: 再试试: 3 | bash : l: command not found |
开个玩笑,把一个重要命令的别名指定为另一个重要命令: 1 | alias cd = 'ls -l' ( set alias of ls -l to cd ) |
2 | alias su = 'pwd' ( set alias of pwd to su ) |
4 | (You can create your own) |
想想多么有趣,现在如果你的朋友敲入‘cd'命令,当他看到的是目录文件列表而不是改变目录; 当他试图用’su‘命令时,他会进入当前目录。你可以随后去掉别名,向他解释以上情况。
29.命令: df报告系统的磁盘使用情况。在跟踪磁盘使用情况方面对于普通用户和系统管理员都很有用。 ‘df‘ 通过检查目 录大小工作,但这一数值仅当文件关闭时才得到更新。 03 | Filesystem 1K-blocks Used Available Use% Mounted on |
04 | /dev/sda1 47929224 7811908 37675948 18% / |
05 | none 4 0 4 0% /sys/fs/cgroup |
06 | udev 1005916 4 1005912 1% /dev |
07 | tmpfs 202824 816 202008 1% /run |
08 | none 5120 0 5120 0% /run/lock |
09 | none 1014120 628 1013492 1% /run/shm |
10 | none 102400 44 102356 1% /run/user |
11 | /dev/sda5 184307 79852 94727 46% /boot |
12 | /dev/sda7 95989516 61104 91045676 1% /data |
13 | /dev/sda8 91953192 57032 87218528 1% /personal |
‘df’命令的更多例子请参阅 12 df Command Examples in Linux. 30. 命令: du估计文件的空间占用。 逐层统计文件(例如以递归方式)并输出摘要。 03 | 8 ./Daily Pics/wp-polls/images/default_gradient |
04 | 8 ./Daily Pics/wp-polls/images/default |
05 | 32 ./Daily Pics/wp-polls/images |
06 | 8 ./Daily Pics/wp-polls/tinymce/plugins/polls/langs |
07 | 8 ./Daily Pics/wp-polls/tinymce/plugins/polls/img |
08 | 28 ./Daily Pics/wp-polls/tinymce/plugins/polls |
09 | 32 ./Daily Pics/wp-polls/tinymce/plugins |
10 | 36 ./Daily Pics/wp-polls/tinymce |
11 | 580 ./Daily Pics/wp-polls |
13 | 36 ./Plugins/wordpress-author-box |
15 | 12 ./May Articles 2013/Xtreme Download Manager |
16 | 4632 ./May Articles 2013/XCache |
注意: ‘df‘ 只显示文件系统的使用统计,但‘du‘统计目录内容。‘du‘命令的更详细信息请参阅 10 du (Disk Usage) Commands.
|