Linux命令中的rmdir

rmdir命令,该命令的功能是删除空目录。一个目录删除之前必须是空的。删除目录的时候也必须具有对父目录的写权限。

命令格式:rmdir [选项]   目录

命令功能:该命令从一个目录中删除一个或者多个子目录项,删除目录的时候也必须对父目录有写权限。

命令实例:

[root@centos65 local]# cd liumengyang
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# ll
total 0
drwxr-xr-x 2 root root 6 Aug 19 08:46 hello
drwxr-xr-x 2 root root 6 Aug 19 08:46 hi
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# cd ..
[root@centos65 local]# 
[root@centos65 local]# 
[root@centos65 local]# 
[root@centos65 local]# rmdir liumengyang
rmdir: failed to remove `liumengyang': Directory not empty

当目录不为空的时候,不能够删除该目录


drwxr-xr-x 2 root root     6 Sep 23  2011 bin
drwxr-xr-x 2 root root 65536 Aug 19 08:52 data
drwxr-xr-x 2 root root     6 Sep 23  2011 etc
drwxr-xr-x 2 root root     6 Sep 23  2011 games
drwxr-xr-x 5 root root  4096 Aug 18 18:07 importsource
drwxr-xr-x 2 root root    32 Jan 14  2015 include
drwxr-xr-x 2 root root     6 Sep 23  2011 lib
drwxr-xr-x 2 root root     6 Sep 23  2011 lib64
drwxr-xr-x 2 root root     6 Sep 23  2011 libexec
drwxr-xr-x 2 root root     6 Aug 19 08:53 liumengyang
drwxr-xr-x 2 root root     6 Sep 23  2011 sbin
drwxr-xr-x 5 root root    46 Dec  4  2013 share
drwxr-xr-x 3 root root    22 Aug 17 12:42 sourcedata
drwxr-xr-x 2 root root     6 Sep 23  2011 src
[root@centos65 local]# cd liumengyang
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# ll
total 0
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# mkdir hello
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# ll
total 0
drwxr-xr-x 2 root root 6 Aug 19 08:53 hello
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# 
[root@centos65 liumengyang]# cd ..
[root@centos65 local]# 
[root@centos65 local]# 
[root@centos65 local]# rmdir -p liumengyang/hello
[root@centos65 local]# 
[root@centos65 local]# 
[root@centos65 local]# ll
total 96
drwxr-xr-x 2 root root     6 Sep 23  2011 bin
drwxr-xr-x 2 root root 65536 Aug 19 08:52 data
drwxr-xr-x 2 root root     6 Sep 23  2011 etc
drwxr-xr-x 2 root root     6 Sep 23  2011 games
drwxr-xr-x 5 root root  4096 Aug 18 18:07 importsource
drwxr-xr-x 2 root root    32 Jan 14  2015 include
drwxr-xr-x 2 root root     6 Sep 23  2011 lib
drwxr-xr-x 2 root root     6 Sep 23  2011 lib64
drwxr-xr-x 2 root root     6 Sep 23  2011 libexec
drwxr-xr-x 2 root root     6 Sep 23  2011 sbin
drwxr-xr-x 5 root root    46 Dec  4  2013 share
drwxr-xr-x 3 root root    22 Aug 17 12:42 sourcedata
drwxr-xr-x 2 root root     6 Sep 23  2011 src

rmdir -p 目录路径     当子目录删除完毕的时候,父目录变为空。则父目录也一并被删除。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值