How to use the mkdir command in Linux

Created

mkdir command in Linux allows the user to create directories (also referred to as folders in some operating systems ). This command can create multiple directories at once as well as set the permissions for the directories.

New Directory
mkdir newdir
Help
mkdir --help
info mkdir
man mkdir
version information
mkdir --version
mkdir (GNU coreutils) 8.22

How to Create Parent Directories

make parent
mkdir -p /data/go
print a message
mkdir -v -p /data/go
mkdir: created directory ‘folder’

The syntax for the mkdir command is as follows:

Usage: 
  mkdir [OPTION]... DIRECTORY...

OPTIONS:
-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
-Z
set SELinux security context of each created directory to the default type
--context[=CTX]
like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
--help
display this help and exit
--version
output version information and exit

Related Tags

#Linux# #mkdir#