Create a Directory
The command to create a directory is
mkdir [options] dir_name
|You must have write permission for the directory that you want to create a new directory in.|
For example, to create a new directory named
birds under the
pet directory, you would type:
You can use
ls command to check if the
birds directory was created successfully.
The tree below has been updated and now includes
You can create a directory in a specific path. For example, to create a directory called
thirdDir in the path
firstDir/secondDir, you would type:
secondDir don’t exist, you will get an error
cannot create directory. To avoid such an error, you can use -p flag.
-p enables the command to create parent directories as necessary. If the directories exist, there will be no error message and the directory will be created. The previous example can be rewritten as follows.
mkdir -p firstDir/secondDir/thirdDir
secondDir don’t exist, using -p option, mkdir will create these directories automatically.