Make directories in Linux with mkdir command.

Step by step example
using mkdir command to make directories in Linux Fedora.

The Linux system usually
contains several thousands Directories (folder). The directory usually contains files and other
directories. All of these directories and files make an filesystem
structures for the Linux operating system. Usually the Linux
filesystem structure are base on
Filesystems Hierarchy Standard
(FHS).
In Linux or other UNIX like
operating system, the directories tree begin with the ' / ' root
directory. The example below show the step by step on making
directories or make folder in Linux fedora core using mkdir command.

Example on Linux directory
tree on Linux Fedora Core:

[root@fedora /]#
tree -L 1

/

|-- bin

|-- boot

|-- dev

|-- etc

|-- home

|-- lib

|-- lost+found

|-- media

|-- misc

|-- mnt

|-- net

|-- opt

|-- proc

|-- root

|-- sbin

|-- selinux

|-- srv

|-- sys

|-- tmp

|-- tree.txt

|-- usr

`-- var

21 directories, 1 file

Making directory in Linux
system.

The Linux command that is usually
issue to make an directory in Linux is mkdir command. This example show you on how to
create directory called new-linux-directory in your current directory:

[root@fedora ~]#
pwd

/root

[root@fedora ~]#
mkdir new-linux-directory

[root@fedora ~]# ls -l

total 104

-rw------- 1 root root 1209 Apr 9 21:38 anaconda-ks.cfg

drwx------ 2 root root 4096 Apr 8 19:06 Desktop

-rw-r--r-- 1 root root 28948 Apr 9 21:26 install-fedora.log

-rw-r--r-- 1 root root 4152 Apr 9 19:56 install.log.syslog

drwxr-xr-x 2 root root 4096 Jun 16
18:46 new-linux-directory

-rw-r--r-- 1 root root 28948 Apr 9 21:26 X.txt

[root@fedora ~]#

Note: The 'ls -l' command above is use to verify the existents of
the newly created directoy.

Make several directory.

The command example below show on how to make several directory in one
go.

There are 3 directory created after the execution of the command above,
use the ' ls ' command to verify the creations of the directories.

Create directory tree.

To create a Linux directory
tree with four subdirectories in current directory, using the mkdir
command.

[root@fedora ~]#
pwd

/root

[root@fedora ~]#
mkdir -p make/directory/with/linux/mkdir/

[root@fedora ~]# tree make/

make/

`-- directory

`-- with

`-- linux

`-- mkdir

4 directories, 0 files

[root@fedora ~]# tree -p make/

make/

`-- [drwxr-xr-x] directory

`-- [drwxr-xr-x] with

`-- [drwxr-xr-x] linux

`-- [drwxr-xr-x]
mkdir

[root@fedora ~]#

There are 1 directory created after the execution of the command above,
but there is 4 other directories are created inside that directory, this
directories usually known as an sub-directory, again use the ' ls ' command to verify the creations of the directory, and you
can use the ' tree ' command to view the sub-directory.

Make directory and change directory permission on one go.

From the example above we can
see that all directory permission created automatically. This
directory permission are set according to your default umask setting.

For example, to
create a directory, with the permission 777 to file:

read,
write,
execute (r,w,x) for user;

read,
write and execute (r,w,x) for group user;

and
read,
write and
execute (r,w,x) for other user on the system
(world).

This permission basically
allow everyone on the system to read,
write and
execute.

The mkdir command below is
issue with the -m option to change the directory permission:

[root@fedora ~]#
mkdir -m 777 linux-directory

[root@fedora ~]# ls -l

total 104

-rw------- 1 root root 1209 Apr 9 21:38 anaconda-ks.cfg

drwx------ 2 root root 4096 Apr 8 19:06 Desktop

-rw-r--r-- 1 root root 28948 Apr 9 21:26 install-fedora.log

-rw-r--r-- 1 root root 4152 Apr 9 19:56 install.log.syslog

drwxrwxrwx 2 root root 4096 Jun 16
19:20 linux-directory

-rw-r--r-- 1 root root 28948 Apr 9 21:26 X.txt

[root@fedora ~]#

Other options that can be use with
mkdir command:

• -m, --mode, To set the access
permission to the directory.

• -p, --parents, Make any missing parent
directories as needed, no error if parent existing.