The mkdir command is used to create (or make) a directory. You supply the name of the directory as an argument. The rmdir directory is used to remove directories, but only those that are empty (i.e., contain no files or subdirectories). In order to delete a directory with actual contents, you must use the rm -R command.

Syntax

The syntax of the mkdir and rmdir commands is:

# mkdir/rmdir {directory names}

mkdir Command Examples

1. To make the directory:

2. To set file mode while making the directory:

# mkdir -m 
# mkdir --mode=MODE 

3. To make parent directories if needed:

# mkdir -p /support/mike
# mkdir --parents /support/mike 

4. To set to verbose mode:

# mkdir -v
# mkdir --verbose 

5. To set the SELinux security context of each created directory to CTX:

# mkdir -Z
# mkdir --context=CTX 

6. To get the help:

7. To output the version information:

rmdir Command Examples

1. To remove an empty directory:

2. To ignore each failure that is solely because a director:

# rmdir --ignore-fail-on-non-empty 

3. To remove DIRECTORY and its ancestors:

# rmdir -p /mike/mydir
# rmdir --parents /mike/mydir 

4. To output a diagnostic for every directory processed:

# rmdir -v /mike/mydir
# rmdir --verbose /mike/mydir 

5. To get the help:

6. To get the version: