Linux mkdir command: create a directory (folder)

mkdir command, make directories is the acronym used to create a new directory, this command all users can use.

 

The basic format mkdir command is:

[Root @ localhost ~] # mkdir [-mp] directory name

  • -m option to manually configure the permissions of the created directory, rather than using the default permissions.
  • -p option recursively all directories created to create a / home / test / demo, for example, by default, you need to create one level of each directory, and use the -p option, the system will automatically help you create / home , / home / test and / home / test / demo.

[Example 1] to create the directory.

[root@localhost ~]#mkdir cangls
[root@localhost ~]#ls
anaconda-ks.cfg cangls install.log install.log.syslog

We create a directory called cangls, you can view the catalog has been established by the ls command. Note that we use in the creation of the directory is a relative path, so this directory is built into the current directory.

[Example 2] using the -p option to recursively create directories.

[root @ localhost ~] # mkdir LM / Movie / jp / cangls
mkdir: can not create directory "lm / movie / jp / cangls ": No such file or directory
[root @ localhost ~] # mkdir -p lm / movie / jp / cangls
[root @ localhost ~] # LS
Anaconda-ks.cfg cangls install.log install.log.syslog LM
[root @ localhost ~] # LS LM /
Movie
# here to see only a subdirectory, in fact, subsequent jp directory , cangls directory have been established

[Example 3] -m option to customize the directory permissions.

[root@localhost ~]# mkdir -m 711 test2
[root@localhost ~]# 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

A close look at the permissions section above, the first column of data (the green part) is the output of the ls command, test and test1 directory because it is not using the -m option to set access permissions, so these two directories uses default permissions (here The default value is 755 permissions, and then later chapters describes the default permissions in detail).

And when you create test2, use the -m option to give new directory permissions drwx-x-x by setting 711 permissions value, the value of the specific meaning of the relevant authority is also introduced into the following chapters.

Published 33 original articles · won praise 0 · Views 395

Guess you like

Origin blog.csdn.net/linuxanz/article/details/103474982