发布于2026-08-13 阅读(0)
扫一扫,手机访问
基本格式:
mkdir [选项] 目录名称[root@server-01 ~]# mkdir --help
Usage: mkdir [OPTION]... DIRECTORY...
Create the DIRECTORY(ies), if they do not already exist.
Mandatory arguments to long options are mandatory for short options too.
-m, --mode=MODE set file mode (as in chmod), not a=rwx - umask
-p, --parents no error if existing, make parent directories as needed
-v, --verbose print a message for each created directory
-Z set SELinux security context of each created directory
to the default type
--context[=CTX] like -Z, or if CTX is specified then set the SELinux
or SMACK security context to CTX
--help display this help and exit
--version output version information and exit
GNU coreutils online help:
For complete documentation, run: info coreutils 'mkdir invocation'常用选项:
[root@server-01 ~]# mkdir --version
mkdir (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Da vid MacKenzie. mkdir testmkdir -p /test/a/b/cmkdir -m 755 test[root@server-01 ~]# ls -ld test/
drwxr-xr-x 2 root root 4096 Sep 1 22:42 test/[root@server-01 ~]# mkdir -pv test/a/b/c/d
mkdir: created directory ‘test/a’
mkdir: created directory ‘test/a/b’
mkdir: created directory ‘test/a/b/c’
mkdir: created directory ‘test/a/b/c/d’.
使用 mkdir 命令时,有几个细节值得先留意一下:
rmdir [选项] 目录名常见的选择主要有:
rmdir dirname[root@server-01 ~]# ls -ld test/a/b/c/d/
drwxr-xr-x 2 root root 4096 Sep 1 22:44 test/a/b/c/d/
[root@server-01 ~]# rmdir test/a/b/c/d/
[root@server-01 ~]# tree ./test/
./test/
└── a
└── b
└── c
3 directories, 0 filesrmdir -p dirname[root@server-01 ~]# ls -ld test/a/b/c/
drwxr-xr-x 2 root root 4096 Sep 1 22:58 test/a/b/c/
[root@server-01 ~]# rmdir -p test/a/b/c/
[root@server-01 ~]# ls test
ls: cannot access test: No such file or directoryrmdir -v dirname[root@server-01 ~]# rmdir -pv test/a/b/c/d/
rmdir: removing directory, ‘test/a/b/c/d/’
rmdir: removing directory, ‘test/a/b/c’
rmdir: removing directory, ‘test/a/b’
rmdir: removing directory, ‘test/a’
rmdir: removing directory, ‘test’
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
4
5
6
7
8
9