Mkdir Command in Linux

mkdir command stands for make directory allows the user to create an empty directory on Linux operating system. This command can also create multiple folders at once as well as set permissions for folders. Of course, pay attention to the permission to create the user’s directory when standing in the parent directory or not? Otherwise, you will get an error message about permission denied.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system commands queries.

In this context, we shall look into how to use the mkdir command through several examples.


What is the syntax of mkdir command ?

It's syntax is give below:

$ mkdir [options] name

For example, We will create a directory named linuxapt:

$ mkdir linuxapt

Now, if this directory have files then you can list them with the ls command:

$ ls

Its options is given below:

  • –version check your version: $ mkdir --version
  • –help display help information: $ mkdir --help
  • -v show folder creation process: $ mkdir -v [name]
  • -p create a directory with parent directory level: $ mkdir -p [name] . For example, We will create the linux1 directory inside the linux2 directory: $ mkdir -p -v linux1/linux2
  • -m create folders with specific permissions: $ mkdir -m [permission_value] name . For example, We want to create a directory named best with all permission: $ mkdir -m a=rwx best


[Need assistance in fixing Linux system issues? We can help you. ]

This article covers how to use the mkdir command with some examples. In fact, The mkdir command in Linux/Unix allows users to create or make new directories. mkdir stands for "make directory". With mkdir, you can also set permissions, create multiple directories (folders) at once, and much more.

Related Posts