≡ Menu

Linux: Howto Make a Directory Command

How do I make directory under Linux operating systems using the command prompt or bash shell?

You need to use the mkdir command to create new folders or directories under Linux operating systems. A directory (also known as folder in MS-Windows/OS X) is nothing but a container for other directories and files.

mkdir command Syntax

The mkdir command has the following syntax:

mkdir dirname
OR
mkdir dirname1 dirname2
OR
mkdir [option] dieNameHere
OR
mkdir -p dir1/dir2/dir3

Examples

Open a terminal and use the mkdir command to create empty directories. The following command would create a directory called foo:
$ mkdir foo
To list directories, enter:
$ ls
$ ls -l

The following command would create two directories within the current directory:
$ mkdir tom jerry
$ ls -l

The -p option allows you to create parent directories as needed (if parent do not already exits). For example, you can create the following directory structure:
$ mkdir -p ~/public_html/images/trip

Sample mkdir demo

Animated gif 01: mkdir in action under Linux / Unix like operating systems

Animated gif 01: mkdir in action under Linux / Unix like operating systems

See also
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 9 comments… add one }
  • Abhishek January 10, 2014, 7:27 am

    I really love your concepts of .gif file, which first time anyone assumes, it is a video.

    Hats off to You :)

    And yes, thank you very much, Whenever I need to learn something regarding linux commands, I used to check from your website.

    Thank You Very Much For That

    • Nix Craft January 10, 2014, 9:33 am

      You are welcome, and thanks for the kind comments!

  • Antony James January 20, 2014, 5:45 am

    Very Gooddd……….

    • osman June 2, 2016, 10:30 am

      Stop lying plss

  • varun vishal January 24, 2014, 8:46 am

    sahi hai boss

  • Ashay February 15, 2015, 5:03 am

    Thanks, I can now finally create a directory in my VPS.

  • Luis August 12, 2015, 4:34 pm

    Thanks for share. this info was useful to me.

  • ravi kumar June 18, 2016, 2:01 am

    Can we find another way to create the nested directory in a single directory

  • courtney November 28, 2016, 2:28 pm

    details is great really help me with my course work

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: , ,