2.1基本命令
2.1.1目录及文件的基本操作
- pwd
描述:pwd命令的作用是显示当前工作目录的名称。
用法:pwd [选项]…
选项:-P显示链接的真实路径。
[root@centos6 Desktop]# pwd
/root/Desktop
[root@centos6 test]# pwd
/tmp/test
[root@centos6 test]# pwd -P
/tmp/pass
#返回当前工作目录/root/Desktop
#返回当前工作目录/tmp/test
#返回链接的真实路径/tmp/pass1 - cd
描述:cd命令的作用是切换当前工作目录。
/tmp/test 是/tmp/pass 的链接文件o
• 31 •第2章命令工具
[root@centos6 test]# du -sh/root
#查看/root所占磁盘空间总和
2.1.2 查看文件内容 - cat
描述:查看文件内容。
用法:cat [选项]…[文件]…
选项:-b显示行号,空白行不显示行号。
-n显示行号,包括空白行。
[root@centos6 test]# cat /root/install.log
[root@centos6 test]# cat -n /etc/passwd
[root@centos6 test]# cat -b /etc/passwd - more
描述:分页查看文件内容,通过空格键查看下一页,q键则退出查看。
[root@centos6 test]# more /root/install.log - less
描述:分页查看文件内容,空格(下一页)、方向键(上下回翻)、q键(退出查看)。
[root@centos6 test]# less /root/install.log - head
描述:查看文件头部内容,默认显示前10行。
用法:head [选项]…[文件]…
选项:-c nK 显示文件前nKB的内容。
-n 显示文件前n行的内容。
[root@centos6 test] # head -c 2K /root/install. log #查看文件的前2KB 的内容
[root@centos6 test] # head -20 /root/install. log #查看文件的前20行的内容 - tail
描述:查看文件的尾部内容,默认显示末尾10行。
用法:tail [选项]…[文件]…