1.7 KiB
		
	
	
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1.7 KiB
		
	
	
	
	
		
			Executable File
		
	
	
	
	
The mkdir command
The mkdir command in Linux/Unix is used to create a directory.
Syntax
$ mkdir [-m=mode] [-p] [-v] [-Z=context] directory [directory ...]
Examples
- Make a directory named myfiles.
$ mkdir myfiles
- Create a directory named myfiles at the home directory:
$ mkdir ~/myfiles
- Create the mydir directory, and set its file mode (-m) so that all users (a) may read (r), write (w), and execute (x) it.
$ mkdir -m a=rwx mydir
You can also create sub-directories of a directory. It will create the parent directory first, if it doesn't exist. If it already exists, then it move further to create the sub-directories without any error message.
For directories, this means that any user on the system may view ("read"), and create/modify/delete ("write") files in the directory. Any user may also change to ("execute") the directory, for example with the cd command.
- Create the directory /home/test/src/python. If any of the parent directories /home, /home/test, or /home/test/src do not already exist, they are automatically created.
$ mkdir -p /home/test/src/python
Options
| Short Flags | Long Flags | Descriptions | 
|---|---|---|
| -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 | --context=CTX | Set the SELinux security context of each created directory to CTX. | 
| - | --help | Display a help message and exit. | 
| - | --version | Output version information and exit. |