rmdir

命令功能:

删除空目录


语法:

rmdir[-p] 目录名称 rmdir仅能删除空目录


参数:

-p :连同上层“空的”目录也一起删除



命令实践:

-rw-r--r-- 1 root root       0 Apr 5 14:36 oldboy.txt

-rw-r--r-- 1 root root      18 Apr 5 14:47 test.txt

drwxr-xr-x 2 root root    4096 Apr 11 11:53 yubing

[root@yubinghost ~]#

[root@yubinghost ~]# rmdir yubing   删除目录

[root@yubinghost ~]# ll

total 8476

-rw------- 1 root root     939 Apr 3 12:38 anaconda-ks.cfg

-rw-r--r-- 1 root root 3422452 Apr  8 10:57 etc.tar.bz2

-rw-r--r-- 1 root root 5172939 Apr  8 10:55 etc.tar.gz

-rw-r--r-- 1 root root   23947 Apr 3 12:37 install.log

-rw-r--r-- 1 root root    3619 Apr 3 12:37 install.log.syslog

-rw-r--r-- 1 root root      18 Apr 5 14:43 o1

-rw-r--r-- 1 root root       0 Apr 5 14:36 oldboy.txt

-rw-r--r-- 1 root root      18 Apr 5 14:47 test.txt

[root@yubinghost ~]# mkdir yubing

[root@yubinghost ~]# touch yubing/yubing.txt

[root@yubinghost ~]# cd yubing; ll

total 0

-rw-r--r-- 1 root root 0 Apr 11 12:05yubing.txt   在目录里创建一个新文件

[root@yubinghost yubing]# cd

[root@yubinghost ~]# rmdir yubing

rmdir: yubing: Directory not empty     目录不为空无法删除

[root@yubing ~]# rmdir /yu/bing/first

[root@yubing ~]#rmdir -p /yu/bing   bing目录以及上层目录都删除了

rmdir: /: Deviceor resource busy    

[root@yubing ~]#rmdir -pv /yu/bing/first

rmdir: removingdirectory, /yu/bing/first

rmdir: removingdirectory, /yu/bing

rmdir: removingdirectory, /yu

rmdir: removingdirectory, /           竟然是从底层目录一直删除到最上层目录

rmdir: /: Deviceor resource busy          只要成为空目录都会被删除