The mkdir command on Ubuntu allows users to create new directories if they do not already exist on the file systems.
This post shows new users and students what the mkdir command is used for and how to use it. For students and new users learning how to use Linux systems, the easiest place to start might be on Ubuntu Linux OS.
Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.
When you’re ready to learn how to use the mkdir commands, follow the guide below:
About mkdir command:
The mkdir command on Ubuntu allows users to create new directories if they do not already exist on the file systems. Like using your mouse and keyboard to create new folders. the mkdir is the way to do it on the command line.
The syntax is the rule and format of how the mkdir command can be used. the syntax can options can be reordered. but a straight format must be followed.,.
Below is an example syntax of how to use the mkdir command.
mkdir [OPTION]. DIRECTORY.
The command line options are switches or flags that determined how the commands are executed or controlled. they modify the behavior of the command. they are separated by spaces and followed after the commands options.
Below are some options for the mkdir command:
|DIRECTORY.||Replace DIRECTORY .. with the name of the directory you want to create. If the specified directory does not already exist, mkdir creates it.|
|Use the -m or –mode option set file mode (as in chmod), not a=rwx – umask. The syntax of MODE is the same as with the chmod command.|
|Use the -p or –parents option to make parent directories as needed|
|Verbose output. Print a message for each created directory.|
|-Z||Use the -Z option to set SELinux security context of each created directory|
to the default type
|–help||Use the –help option with the command to display this help and exit|
|–version||Use the –version option to output version information and exit|
Below are some examples of how to run and use the mkdir on Ubuntu Linux.
Run the command below to create a new directory called Confidential without any mkdir command options. This will just create a simple directory or folder called Confidential.
You can use the mkdir command with the -m or –mode option to create a directory and specify the permissions as well. For example, to create a directory or folder called Confidential and set permission, run the commands below.
mkdir -m a=rwx Confidential
The above command will create a Confidential directory and give all users = read, write, and execute permissions. (a = read, write, execute)
When you run mkdir with the –help option, you’ll see the help text below:
Usage: mkdir [OPTION]. DIRECTORY. Create the DIRECTORY(ies), if they do not already exist. Mandatory arguments to long options are mandatory for short options too. -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
Hope you like it and please come back soon for more Ubuntu Linux command!