Last Updated on May 22, 2022
mkdir
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.
Pages in this article:
Page 1 – cp
Page 2 – mv
Page 3 – rm
Page 4 – mkdir
All articles in this series:
Thanks. How many parts will this guide be?
We’re not certain of the final number of parts, but there’s plans for quite a few more. And we’re open to suggestions for additional areas that would help a beginner to Linux, or topics already covered where additional material would be welcome.