mkdir

>Usage

The mkdir command is used for creating folders super easily. It can create multiple directories at once as well as set the permissions for the directories.

Note that the user executing this command must have enough permission to create a directory in the parent directory.

>Synopsis

mkdir [option] directory_name

>Features

With mkdir dir{1..4} it's possible to create multiple directories and list them from 1 to 4 with only one command.

Example:

Dots

-zsh

> mkdir -v dir{1..4}


dir1
dir2
dir3
dir4

With mkdir dir1 dir2 it's possible to create two directories with only one command.

Example:

Dots

-zsh

> mkdir -v dir_1 dir_2


dir_1
dir_2

>Options

-v

By using this option a message is provided for each directory that is created.

Example:

Dots

-zsh

> mkdir -v dir_1


dir_1

-m

By using this option it's possible to set the permissions for the new directory using a numeric code. The number is characterized by 3 digits.

The first digit represents the permissions of the owner, the second one the permissions of the group and the last one the permission of Others.

7= read, write, execute permissions.
6= read and write.
5= Read and execute.
4= read.
0= no permission

Assume that you want to create a folder dir_1 and give all the permissions only to the owner.

Example:

Dots

-zsh

> mkdir -vm 700 dir_1


dir_1

-p

By using this option it's possible to create directory inside the specified path.

Assume that you want to create a folder dir_1 in the path /user/home/Document/dir but dir doesn't exist, this command will create dir and then dir_1 inside of it.

Example:

Dots

-zsh

> mkdir -vp /home/user/Document/dir


dir
dir/dir_1

>Quiz

Progress: Question ? out of ?

Question Title

Page written by Gabriele Siliprandi