-
Linux系统入门分类的最新文章
-
最新评论
-
猎鹰炯炯:谢谢马哥的评论!我会更加的努力学习您所转授的知识,
-
最新文章
-
目录
-
【功能】
mkdir - make directories :创建目录,其及同时创建多个目录
【SYNOPSIS】
mkdir [OPTION] DIRECTORY...
【选项参数】
-m, --mode=MODE :表示创建目录并且赋予目录权限,不是umsk的默认权限 -p, --parents :表示创建一个多个目录并且关系是父子目录 -v, --verbose :表示显示出已经创建完成的目录信息
【实例1】
创建目录并且给目录赋权
[root@localhost test]# mkdir DirTest1 [root@localhost test]# ls -ld DirTest1/ drwxr-xr-x 2 root root 4096 Jul 17 13:56 DirTest1/ 默认创建目录的权限 [root@localhost test]# mkdir -m 770 DirTest2 [root@localhost test]# ls -ld DirTest2 drwxrwx--- 2 root root 4096 Jul 17 13:57 DirTest2 给目录赋予权限
【实例2】
同时创建多个目录并且赋权
[root@localhost test]# mkdir -m 700 a b c d e [root@localhost test]# ls -ld a b c d e drwx------ 2 root root 4096 Jul 17 14:01 a drwx------ 2 root root 4096 Jul 17 14:01 b drwx------ 2 root root 4096 Jul 17 14:01 c drwx------ 2 root root 4096 Jul 17 14:01 d drwx------ 2 root root 4096 Jul 17 14:01 e
【实例3】
创建多个目录并且是父子目录关系
[root@localhost test]# mkdir o/p/q/r mkdir: cannot create directory `o/p/q/r': No such file or directory [root@localhost test]# mkdir -p o/p/q/r [root@localhost test]# ls -R o o: p o/p: q o/p/q: r o/p/q/r:
【删除目录】rmdir
1、使用rmdir删除a目录
[root@localhost test]# ls a d filetest lost+found test2.txt test.txt x acle.sh Desktop hellosa o test6.txt testuser.sh adduser2 DirTest1 history1.sh scsrun.log testdie third.sh anaconda-ks.cfg DirTest2 install.log sencd.sh testfile ugideq.sh b e install.log.syslog sort.t testquit2.sh usertest c echo $? l sum.sh testquit.sh usertestid [root@localhost test]# rmdir a [root@localhost test]# ls acle.sh Desktop hellosa o test6.txt testuser.sh adduser2 DirTest1 history1.sh scsrun.log testdie third.sh anaconda-ks.cfg DirTest2 install.log sencd.sh testfile ugideq.sh b e install.log.syslog sort.t testquit2.sh usertest c echo $? l sum.sh testquit.sh usertestid d filetest lost+found test2.txt test.txt x [root@localhost test]#
2、使用rmdir无法删除非空目录
[root@localhost test]# ls -R o o: p o/p: q o/p/q: r o/p/q/r: [root@localhost test]# rmdir o rmdir: o: Directory not empty
以上为mkdir创建目录的常用操作选项,但是在实际环境中并不会使用rmdir去删除目录
0
收藏
Ctrl+Enter 发布
发布
取消