linux mkdir command – make directories
Linux mkdir command is used to create directories. If the directory does not exist, it is created.
Syntax
mkdir [OPTION]... DIRECTORY...
Options
- -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
Examples & Use Cases
Create multiple directories
In the following example we will create multiple directories under the current directory at the same time.
➜ mkdir dir-1 dir-2 dir-3
Create parent and child directory
In the following example, we are creating a multi-level directory, with both parent and child directories.
➜ mkdir -p parent/child
Create directory and set permissions
In the following example, directory permissions are set when the directory is created.
➜ mkdir -m 777 directory