Linux is an open-source operating system that is similar to Unix-based operating systems such as MacOS. It provides a command line, essentially a graphical user interface for system users to enter shell commands they want to execute on the system. One of these commands is the mkdir
command.
mkdir
commandThe mkdir
command creates a new folder in the system as the command's name comes from the words "make directory."
Below, we can see the syntax for the command.
mkdir [OPTION] folderName
The folderName
represents a placeholder where we must enter the name of the folder we want to create.
If we want to create a folder named myFolder
, we'll use the following command:
mkdir myFolder
We can also add the command parameters in place of OPTION
shown in the syntax above.
The table below shows the different parameters we can use alongside the command.
Parameter | Description |
| Sets the file permissions at the time of creation. |
| Makes the parent directories if they do not already exist. |
| Displays a message for each file created. |
| In a SELinux-enabled kernel, this option sets the security context of each created directory to the specified context. |
| Displays the version. |
| Opens the command's manual. |
Below, we can see examples of the parameters mentioned in the table above.
--mode
parameterIf we want to create a directory myFolder
with all permissions of users and no permissions for groups and others, we will use the command:
mkdir --mode 0700 myFolder
--parents
parameterIf we want to create a directory etc/user/folder
but the folder etc
and user
do not exist, we can use the parents
argument to create these folders as shown below.
mkdir --parents etc/user/folder
--verbose
parameterIf we want to display a message, the created directory myFile
created, we can use the following command:
mkdir --verbose myFile
-Z
parameterLet's suppose we are making a folder newFolder
and we want it to have the default SELinux security context; we can use the command:
mkdir -Z newFolder
--version
parameterIf we want to display the version information for the command, we can execute the following command:
mkdir --version
--help
parameterTo open the manual of the mkdir
command we can use the following command.
mkdir --help
Below, we can see a terminal in which we can use the mkdir
command and pass the above parameters to the command to see how they work.
Now that we have gone through what is the mkdir
command and its parameters, let's try to solve the quiz attached below.
What does mkdir
stand for?
Make Directory
Move Directory
Main Directory
Free Resources