mkdir
command is used to create new folders and directories. mkdir
have very little options but because of the mkdir
command importance, we will examine these options.
mkdir
命令用于创建新的文件夹和目录。 mkdir
选项很少,但是由于mkdir
命令的重要性,我们将研究这些选项。
Linux选项 (Linux Options)
There are more Linux options than Windows operating systems option. We will look these Linux options below.
Linux选项比Windows操作系统选项更多。 我们将在下面查看这些Linux选项。
帮助选项 (Help Option)
We can print help information about the mkdir
command options. We will use --help
in order to print help information about options.
我们可以打印有关mkdir
命令选项的帮助信息。 我们将使用--help
来打印有关选项的帮助信息。
$ mkdir --help

设置文件夹和目录模式(Set Folders and Directories Mode)
We can use -m
or --mode
option in order to set permissions about folders and directories which will be created with the mkdir
command. In this example, we will set rwx
.
我们可以使用-m
或--mode
选项来设置有关将使用mkdir
命令创建的文件夹和目录的权限。 在此示例中,我们将设置rwx
。
$ mkdir -m a=rwx test
父选项 (Parent Option)
While creating folders and directories in a recursive fashion, if the parent is not currently existed we will get an error like cannot create directory ‘ismaail/baydan/backup’: No such file or directory
. Because there is o directory like ismail
and baydan
. We can create with a single command multiple child and parent directories by using -p
option. In this example, ismail
and baydan
will be created automatically and then backup
directory will be created without a problem.
当以递归方式创建文件夹和目录时,如果当前不存在父目录,我们将收到类似cannot create directory 'ismaail/baydan/backup': No such file or directory
。 因为有像ismail
和baydan
这样的目录。 我们可以使用-p
选项通过一个命令创建多个子目录和父目录。 在此示例中,将自动创建ismail
和baydan
,然后将创建backup
目录而不会出现问题。
$ mkdir -p ismail/baydan/backup
详细选项 (Verbose Option)
During folder and directory creation there will be no information about process except errors. We can print operations about folder and directory creation with the -v
option like below.
在创建文件夹和目录的过程中,除了错误之外,没有其他有关进程的信息。 我们可以使用-v
选项打印有关文件夹和目录创建的操作,如下所示。
$ mkdir -p ismail/baydan/backup

SELinux选项(SELinux Option)
SELinux is a security mechanism used to protect files and folders access via processes. We can set SELinux context by using --context
option.
SELinux是一种安全机制,用于保护通过进程的文件和文件夹访问。 我们可以使用--context
选项设置SELinux上下文。
Windows选项 (Windows Options)
Windows operating system provides less option than Linux counterpart. We can only print usage information with the help information.
Windows操作系统提供的选择少于Linux操作系统。 我们只能打印使用信息和帮助信息。
帮助选项 (Help Option)
We can print help information with the /?
option like below.
我们可以使用/?
打印帮助信息/?
如下所示的选项。
> mkdir /?

翻译自: https://www.poftut.com/mkdir-command-options-for-linux-and-windows/