Special offer
+370 5 205 5502 sales@monovm.com

How to Create a Folder in Linux [CentOS, Debian, Ubuntu]

You can build new folders in Linux environments using either the command line or the file manager on your desktop. mkdir is a command that helps you to build files, which are also known as folders. So in this tutorial, we will explain complete information and ways to create a folder Linux quickly. 

01 Jun, 21 by Antoniy Yushkevych 3 min Read

A Detailed Breakdown of Linux Folder Creation


How to a Create Folder in Linux 

You can create a folder in Linux easily using the steps given below: 

  1. In Linux, open the terminal command.
  2. The mkdir command is useful for creating new files or directories.
  3. In Linux, enter mkdir dir1 to build a folder with the name dir1.

Let's take a closer look at certain cases and other applications. The syntax is as follows:

mkdir folder

mkdir [option] folderName

mkdir directory

By using the ls command to list the contents of the directory, you can confirm that it was created:

ls -l 

This will show the list of all the current directories. mkdir's -v (--verbose) option instructs it to print a message for each directory it creates.

The file is generated in the current working directory when only the directory name is provided without the complete path. The latest working directory is the location where the commands are being executed. The cd command is used to modify the actual working directory.

To build a directory in a different region, you'll need to specify the parent directory's absolute or relative file direction.  To construct a new directory in the /xyz directory, for example, type:

mkdir /xyz/newdirectory

You'll get a Permission denial error if you want to build a directory in a parent directory where the user doesn't have enough permissions.

mkdir /root/newdirectory

After executing the command you will get output like this: 

mkdir: cannot create directory '/root/newdirectory': Permission denied

You can create a parent folder using the following command:

mkdir -p dir11/dir12

mkdir -p parent1/child1

mkdir -p pictures1/memories1

This will list all the directories present in the parent and child folder, respectively:

ls -l

ls -l pictures1

How to Create a Folder and Assign Permissions to It

New directories are generated with reading, write, and execute permissions by default. To set the permissions of new files, use the -m option with directory:

mkdir -m {permissions} {dirName}

mkdir -m 777 alpha

ls -l

The sequence 777 will be inserted after the -m to construct a directory called alpha with all three forms of permissions available for all users.

How to Make a Multiple-Directory Structure

To construct several folders, use the command arguments to define the directories' names, separated by a space:

mkdir directory1 directory2 directory3

Using the rmdir command/rm command to erase the directory.

Here, we are removing a folder called directory1, so we will execute the below command:

rmdir directory1


rm -rf directory1



In Linux, the mkdir command is used to build new files. We also saw how we could use mkdir to create directories with multiple files, password-protected directories, and parent/child directories. We also saw using the rmdir or rm command, and we can permanently delete the directory.


Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com