The “Make Directory” command in Linux creates a new directory in the file system. Using mkdir command also configures the permissions on newly created directories as well as to construct directories, including nested directories.
Example Code
mkdir [directory]
Where directory is the path of the directory that you want to create.
Special Note:
As you will see in all of the example images we have been using“ls” command. To know more click the link below.
Mkdir command available options
- -p: If the parent directories don’t already exist, you can create them with the -p option. For instance, the -p option will construct the “docs” directory before establishing the “project1” directory if you want to build the directory howto/docs/project1 but the documents directory does not already exist.
- -m: The new directory’s permissions can be set with the -m option. It accepts an octal number as a parameter, which stands for the directory’s permissions. For instance, the command mkdir -m 755 new directory will create a new directory with the owner’s read, write, and execute permissions as well as the group’s and others’ read and execute capabilities.
Special Note
We have set the permission to “777”. To know more about file and folder permission click the link below.
- -v: Use the -v option to show verbose output. It will display the command’s status along with the name of the newly formed directory.
When you need to create a new directory, either to store files or to manage existing files, you frequently use the mkdir command. When you need to construct nested directories and change the permissions on the newly generated directories, the -p and -m arguments come in handy.
It’s important to note that if you don’t specify any permissions while creating a new directory, the default permissions will be applied. The umask value of the user, which governs the file permission for new files and directories, affects the default permissions in several ways.
Itís hard to find knowledgeable people for this subject, but you seem like you know what youíre talking about! Thanks