Last Updated on May 22, 2022
mkdir is a command that creates a directory.
We can create a directory in current directory or given path with the command:
$ mkdir directory
Create directories recursively (useful for creating nested dirs):
$ mkdir -p path/to/directory
The mkdir command is used to create directories.
We can create a directory in the current directory or given path with the command:
$ mkdir dir1
Remember that Linux is case-sensitive. So we can have directories with names dir2, Dir1, DIR1 etc.
It’s also possible to create directories recursively. This lets us create nested directories with a single command: For example, let’s suppose we are in ~/test, and execute the command:
$ mkdir -p mkdir -p dir1/dir2/dir3
The tree command shows the new directories we’ve created.
sde@medway:~/test$ tree . └── dir1 └── dir2 └── dir3
The command rmdir removes a directory. It can only remove empty directories,
To remove directories containing sub-directories (providing they have no files) we can use the command:
$ rmdir -p dir1/dir2/dir3
Removing a directory using a shell command doesn’t place it in the Rubbish Bin. It’s gone forever.
All articles in this series: