Managing Directories
Linux has a few commands that work for both files and directories (such as the cp
command), and some that work only for directories. To create a new directory, you need to use a specific command, which is covered in this section. Removing directories can get interesting, so that is covered in this section as well.
Creating directories
Creating a new directory in Linux is easy — just use the mkdir
command:
$ mkdir New_Dir
$ ls -ld New_Dir
drwxrwxr-x 2 christine christine 4096 May 22 09:48 New_Dir
$
The system creates a new directory named New_Dir
. Notice in the new directory's long listing that the directory's record begins with a d
. This indicates that New_Dir
is not a file, but a directory.
You can create directories and subdirectories in “bulk” if needed. However, if you attempt this with just the mkdir
command, you get the following error message:
$ mkdir New_Dir/Sub_Dir/Under_Dir
mkdir: cannot create directory 'New_Dir/Sub_Dir...