linux---mkdir rmdir指令

mkdir:

[root@linux ~]# mkdir [-mp] 目录名称

参数:
-m :设定档案的权限喔!直接设定,不需要看预设权限 (umask) 的脸色~
-p :帮助你直接将所需要的目录递归建立起来!
范例:
[root@linux ~]# cd /tmp
[root@linux tmp]# mkdir test <== 建立一名为 test 的新目录
[root@linux tmp]# mkdir test1/test2/test3/test4
mkdir: cannot create directory `test1/test2/test3/test4':

No such file or directory <== 没办法直接建立此目录啊!

[root@linux tmp]# mkdir -p test1/test2/test3/test4
# 加了这个 -p 的参数,可以自行帮您建立多层目录!
[root@linux tmp]# mkdir -m 711 test2
[root@linux tmp]# ls -l
drwxr-xr-x 3 root root 4096 Jul 18 12:50 test

drwxr-xr-x 3 root root 4096 Jul 18 12:53 test1
drwx--x--x 2 root root 4096 Jul 18 12:54 test2


rmdir (删除『空』的目录)

root@linux ~]# rmdir [-p] 目录名称
参数:
-p :连同上层『空的』目录也一起删除
范例:
[root@linux tmp]# ls -l
drwxr-xr-x 3 root root 4096 Jul 18 12:50 test
drwxr-xr-x 3 root root 4096 Jul 18 12:53 test1
drwx--x--x 2 root root 4096 Jul 18 12:54 test2
[root@linux tmp]# rmdir test
[root@linux tmp]# rmdir test1
rmdir: `test1': Directory not empty
[root@linux tmp]# rmdir -p test1/test2/test3/test4
[root@linux tmp]# ls -l
drwx--x--x 2 root root 4096 Jul 18 12:54 test2
# 瞧!利用 -p 这个参数,立刻就可以将 test1/test2/test3/test4 一次删除~
# 不过要注意的是,这个 rmdir 仅能『删除空的目录』喔!



 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值