linux mkdir code example

Example 1: bash make multiple directories in current directory

# Basic syntax:
mkdir directory1 directory2 directory3 # Make directory1, 2, and 3 in the
#	current directory

Example 2: mkdir - p linux

The -p flag will create nested directories, but only if they dont exist already.

For example, suppose you have a directory /foo that you have write permissions for.

mkdir -p /foo/bar/baz  # creates bar and baz within bar under existing /foo

It is also an idempotent operation, because if you run the same command over again, you will not get an error, but nothing will be created.

Example 3: linux create directory with permissions

mkdir –m777 DirM

Example 4: mkdir command

#usage:
mkdir <name>

#also it can be abbreviated to:
md <name>#in cmd(windows)

#it creates a folder with name <name>