How To Create New Directory / Folder In Linux

Article By bobby


mkdir New Directory on a VPS

Introduction to make new directory

In this post we will learn, how to create new directory in a Linux system. To create a new directory in a Linux system we will use the command called mkdir.

To create a directory in Linux

Use the below given command to create single directory in current path Syntax:
mkdir dir-name

To create multiple directory in Linux

Use the below given command to create multiple directories in current path. Syntax:
mkdir dir-name1 dir-name2 dir-name4 dir-nameN

Create a directory inside existing/non existing parent directory

In case you want to create a directory inside other directory, we will use -p option with mkdir command. Even if the parent directory does not exist, we use -p option with mkdir command to create a new directory tree. Syntax:
mkdir -p dir1/dir2/dir3/MORE-dir 
Example In this case, we have already have a existing directory called DIR1 and we will create new directory inside DIR1 named test1 and test2 . Here , the directory tree structure will look like this DIR1/test1/test2 We will use the command
mkdir -p DIR1/test1/test2

Assigning permission while creating new directory

We can assign permission while creating a new directory. For this we will use -m option with mkdir command Syntax:
mkdir -m PERMISSION-SET directory-name
Example : We will create a directory called orange with permission 400 (Read to Owner only)
test@localhost:~$ mkdir -m 400 orange
test@localhost:~$ ls -ld orange/
dr-------- 2 test test 4096 Mar 14 18:00 orange/

Tags: , , ,

Spin Up A VPS Server In No Time Flat

Simple Setup

Full Root Access

Straightforward Pricing


Leave a Reply