mkdir
mkdir linux command cheatsheet by Thamizhiniyan C S
Last updated
mkdir linux command cheatsheet by Thamizhiniyan C S
Last updated
Command | Description |
---|---|
-p
Creates parent directories if they don't exist.
-m a=[rwx] [dir_name]
Sets the file modes, i.e., permissions, for the new directory.
-v
Displays a message for each created directory.
--version
Displays the version number and information about the license and exits.
-Z
Sets the SELinux security context for directories.
-help
Displays help with information about mkdir options.
To create a single directory named Linux
To create a directory with spaces in its name, enclose the entire directory name in quotes.
To create a directory or directories in a specific location other than your current working directory, specify the full directory path.
This command creates a directory structure with “my_folder” as the parent directory and “sub_folder” as its subdirectory.
To create multiple directories at once, list the directory names separated by a space.
Use mkdir with curly brackets to create multiple directories without spaces.
Create a batch of directories starting with the same pattern, from dir1 to dir15.
mkdir allows you to use environment variables in directory names. This example creates a directory with the current user being the directory name.
To build a structure with multiple subdirectories. This ensures that mkdir adds any missing parent directories in the process. If the directories exist, no error is specified.
If the first and second directories do not exist, due to the -p option, mkdir will create these directories. If the -p option is not specified, an error is returned.
To add all permissions for all users when creating a directory, specify the -m option with 777.
This option is used to set the file modes, i.e. permissions, for the created directories.
Use the ‘-m’ option to set specific permissions for a directory. This command sets read, write, and execute permissions for the owner, and read and execute permissions for others.
To see the details of the mkdir process. It displays a message for every directory created.
It displays help-related information and exits.
It displays the version number, some information regarding the license and exits.