本文索引centos
绝对路径:从根目录/开始的完整路径表示centos7
相对路径:相对于当前所在目录位置的路径表示code
使用pwd能够查看当前所在的目录(绝对路径表示)索引
# ls命令 --> 相对路径表示 [root@centos7 ~]# ls anaconda-ks.cfg test test.cap tmp # ls命令 --> 绝对路径表示 [root@centos7 ~]# /bin/ls anaconda-ks.cfg test test.cap tmp # 查看当前路径 [root@centos7 ~]# pwd /root
切换当前工做目录资源
系统中没有tree命令,能够使用yum进行安装:yum install -y treetest
[root@centos7 ~]# pwd /root # 切换到父目录,这里的父目录就是/ [root@centos7 ~]# cd .. [root@centos7 /]# pwd / # 切换到用户家目录,即/root [root@centos7 /]# cd ~ [root@centos7 ~]# pwd /root # 切换到指定目录 [root@centos7 ~]# cd /home/ # 切换到前次工做目录,即/root [root@centos7 home]# cd - /root
[root@centos7 ~]# mkdir -v /test mkdir: 已建立目录 "/test" [root@centos7 ~]# tree /test/ /test/ 0 directories, 0 files
[root@centos7 ~]# mkdir -p /test/1/2/3 [root@centos7 ~]# tree /test /test └── 1 └── 2 └── 3 3 directories, 0 files
!!不能删除包含文件的目录,只能删除空目录配置
[root@centos7 ~]# touch /test/1/2/3/file [root@centos7 ~]# rmdir -pv /test/1/2/3 rmdir: 正在删除目录 "/test/1/2/3" rmdir: 删除 "/test/1/2/3" 失败: 目录非空
这里有个限制,从最底层开始删除,当哪一层非空,将中止删除。file
[root@centos7 ~]# rmdir -pv /test/1/2/3 rmdir: 正在删除目录 "/test/1/2/3" rmdir: 正在删除目录 "/test/1/2" rmdir: 正在删除目录 "/test/1" rmdir: 正在删除目录 "/test" rmdir: 正在删除目录 "/" rmdir: 删除目录 "/" 失败: 设备或资源忙
相对于rmdir的缺陷command
[root@centos7 /]# mkdir /test [root@centos7 /]# rm -r /test rm:是否删除目录 "/test"?y
[root@centos7 /]# rm -f /test/test.txt [root@centos7 /]# ls /test/test.txt ls: 没法访问/test/test.txt: 没有那个文件或目录
[root@centos7 /]# alias rm alias rm='rm -i'
rm -rf DIR --> 强制删除目录(包括其中的全部文件和目录),不会提示,因此要当心使用!!yum
关于删除过程:先删除最底层目录下的文件,再删除目录,而后依次执行,直至删除完毕。
[root@centos7 /]# touch /test/1/2/3/test.txt [root@centos7 /]# rm -rfv /test 已删除"/test/1/2/3/test.txt" 已删除目录:"/test/1/2/3" 已删除目录:"/test/1/2" 已删除目录:"/test/1" 已删除目录:"/test"
!command:执行历史执行过的command开头的命令
使用history命令能够查看系统历史命令