--- layout: page category-page: fs category-title: FileSystem tags: working directory current position where author: Mirko Ponzio title: mkdir previous-page: pages/fs/ls.html next-page: pages/fs/mv.html --- The mkdir command is used to create new directories
The name stands for MaKe DIRectory.
The default ls command syntax is:
mkdir [flags] [-m mode] directory_name ...
Where [flags] are the mkdir -p and -v - flags, read below for more info, and directory_name is the name of the new directory we are going to create.

Create a new directory

Let's see how to create a new directory:
ls

mkdir test_directory
ls
    test_directory

Create a path of directories

Using the flag -p we can create a path of directories, allowing us to build more than a directory at once.
mkdir -p test_directory/subdir/subsubdir
As you can see, we are now creating two directories: one named subdir and another one, included in this, named subsubdir
The -p flag is necessary to allow the shell to create intermediate directories as required.

Create directories with specified permissions

The -m mode option allows us to set permissions at the new directory that we are now creating.
mkdir -m 777 test_free_directory
Our new directory will now have read,write and execute permissions for user, group and others.