How to Make Directories with mkdir Command and Set Permissions on Linux
Published on Aug. 22, 2023, 12:14 p.m.
Directories are used to store other directories or files in Linux. We can use the mkdir command to make a directory.
How to Make Directory with mkdir Command
We can use the mkdir command to make a directory. The directory name is given to the commanddir as a parameter.
$ mkdir database
How to Make Multiple Directories
We can make multiple directories using the mkdir command. Every directory name is provided as a parameter. The directory names are separated by spaces.
$ mkdir database users backups
If the directory names contain spaces double quotes .
$ mkdir "my database" "my users" "our backups"
How to Make Parent and Child Directories
We can make multi-level directories or parent-child directories with the mkdir command .
$ mkdir -p database/mysql/current/
How to Make a Directory and Set Permissions
The -m option is used to specify permissions.
$ mkdir -m 722 backup