You can create a directory or folder with different ways in Linux. There are many types of Linux directories, for example, some directories for only Kernel uses, the user uses and some operating system directories. We use directories or folders for storing data or files with specific locations for future uses.

In this article, you will learn about creating a directory in Linux using Commands and as well as a graphical user interface.

How to create a directory in Linux Command

Linux Kernel is open source and Linux provides a lot of commands for interacting with operating system. The Linux also provides a “ mkdir ” command for creating a folder or directory in the Linux. The syntax for creating a directory in Linux is given below:  

  • First, open the terminal. Shortcut key ( Ctrl + Alt + T ).
  • Using “ cd ” command go where you want to create a directory. You also check the present directory with “ pwd ” command.
  • Now write the “ mkdir ” command with the name of the directory.

$ mkdir mydirectory

“ mydirectory ” is the name of your newly-created directory.

With “ mkdir ” command in the Linux, you can use “ mkdir ” command for multiple uses as an example, create a subdirectory in existing folder or directory.

Create a subdirectory

Let’s play with “ mkdir ” command a create multiple folders at the same time with a single command.

                                $ mkdir directory1 directory2 directory3

Now you check the newly directories or folders with the Linux basic command “ ls ”.

The uses of mkdir with different scenarios

Let’s discuss in detail about the “ mkdir ” command with different options and also fast techniques for its working.

mkdir –p option:

If you want to create a directory for complete detail with parents, again parents, and again parent then the syntax is given below:

mkdir – p parents/sun/child

mkdir—m777 option:

We know that the Linux is secure operating system. If you are creating a folder you can set its directories permissions for your new directory. “ –m777 ” option give us complete permission on the new directory for reading data from that folder, writing data in that folder and also execution for everyone. Also 775, 700 etc for different user accesses


                               mkdir—m777 mydirectory

mkdir –v option:

“ –v ” is also an important option with “ mkdir ” command but it also works similar to default. But systex is different:

                                mkdir –v myDirectory

How to create a directory in Linux using java

Java is high-level language but JVM provides a better and fast to interact with basic level of Linux. A simple code for creating a new directory in Linux using java is:

                new File ( ‘ yourNewDirectory ‘ ).mkdirs( );

File myDirectory = new File ( ‘ new folder ‘ ) ;

// this code first chechk the availability of directory that name is wirting in command above.

if ( !myDirectory.exists( ) ) {

System.out.println ( ‘ creating directory:  ‘ + myDirectory.getName());

                               boolean result = false;


                               myDirectory.mkdir( );

                               result = true;


                Catch ( SecurityException se ) {

                //handle it


                If ( result ) {   

                               System.out.println ( ‘ DIR created ‘ ) ;



How do you create a directory in Linux terminal?

How to make a folder in Linux
  1. Open the terminal application in Linux.
  2. The mkdir command is is used to create new directories or folders.
  3. Say you need to create a folder name dir1 in Linux, type: mkdir dir1.

How do I create a directory in Unix?

  1. mkdir dirname — make a new directory.
  2. cd dirname — change directory. You basically ‘go’ to another directory, and you will see the files in that directory when you do ‘ls’.
  3. pwd — tells you where you currently are.

How do I copy directories in Linux?

To copy a directory, including all its files and subdirectories, use the -R or -r option. The command above creates the destination directory and recursively copy all files and subdirectories from the source to the destination directory.

What is MD command?

Creates a directory or subdirectory. Command extensions, which are enabled by default, allow you to use a single md command to create intermediate directories in a specified path. Note. This command is the same as the mkdir command.

What is MD in PowerShell?

mkdir is a function defined in PowerShell that uses New-Item cmdlet to create folder(s) and md is an alias to mkdir.

What is MD in batch file?

Make Directory – Create a new folder/directory. Command extensions, which are enabled by default, allow a single MD command to create all the intermediate directories in a specified path. Directories are one type of folder, namely, folders which correspond to file system locations.

What does P mean in Linux?

mkdir –p means: create the directory and, if required, all parent directories. The fact that this makes little sense when the path is specified as . , so the current working directory, does not change this. Most likely the line where the path is defined is meant to be adapted as required.

What does R mean in Linux?

r, –recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option.

What is the use of P in Linux?

Linux provides us a utility called ps for viewing information related with the processes on a system which stands as abbreviation for “Process Status”. ps command is used to list the currently running processes and their PIDs along with some other information depends on different options.

Which is the best Linux OS for beginners?

10 Best Linux Distros For A Beginner User In 2021
  • Linux Distros.
  • Ubuntu.
  • Linux Mint.
  • Kali Linux.
  • Linux Kernel.
  • Coding.

What is Linux OS command?

The Linux command is a utility of the Linux operating system. All basic and advanced tasks can be done by executing commands. The commands are executed on the Linux terminal. The terminal is a command-line interface to interact with the system, which is similar to the command prompt in the Windows OS.

What is symbol called in Linux?

Symbol or Operator in Linux Commands. The ‘!’ symbol or operator in Linux can be used as Logical Negation operator as well as to fetch commands from history with tweaks or to run previously run command with modification.

How do I find Linux?

Check os version in Linux
  1. Open the terminal application (bash shell)
  2. For remote server login using the ssh: ssh user@server-name.
  3. Type any one of the following command to find os name and version in Linux: cat /etc/os-release. lsb_release -a. hostnamectl.
  4. Type the following command to find Linux kernel version: uname -r.

How do you represent in Linux?

For this particular case following code means: Somebody with user name “user” has logged in to the machine with host name “Linux-003″. “~” – represent the home folder of the user, conventionally it would be /home/user/, where “user” is the user name can be anything like /home/johnsmith.

Why do we use Linux?

Installing and using Linux on your system is the easiest way to avoid viruses and malware. The security aspect was kept in mind when developing Linux and it is much less vulnerable to viruses compared to Windows. However, users can install ClamAV antivirus software in Linux to further secure their systems.

Do hackers use Linux?

Linux is an extremely popular operating system for hackers. Malicious actors use Linux hacking tools to exploit vulnerabilities in Linux applications, software, and networks. This type of Linux hacking is done in order to gain unauthorized access to systems and steal data.