FactorPad
Faster Learning Tutorials

Linux mkdir command summary with examples

mkdir allows you to make directories.
  1. Purpose - Learn what mkdir is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with mkdir.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 13, 2016
Updated: July 30, 2018
In this tutorial, 22 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / technology  / linux essentials  / mkdir command


The Linux mkdir command

Beginner

Learn to make directories at the Linux command line.

Video Tutorial

Linux mkdir command summary with examples (3:30)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our twenty-second word, or command to memorize is mkdir from the category Navigation.

mkdir allows you to make directories.

Recall from the last video (tutorial) we created files in other directories, now we'll create directories in other directories.

Before we start, it helps to think about commands as mini programs and most follow this structure: command -option(s) argument(s).

The mkdir command has 6 options and the argument is the name of the one or multiple directories you'd like to create.

Like most commands, help is available, here with double-dash --help.

And for when we get to a discussion on permissions, just remember you can set up permissions at the same time, here using -m.

So why is mkdir an important command? Well, Linux is a text-based system, so you'll need to stay organized by creating directories to hold your stuff. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go, let's make a directory within the current directory.

$ mkdir stuff

Then ls, or list files, using dash -aog to confirm.

$ ls -aog total 28 drwxr-xr-x 3 4096 Oct 13 14:15 . drwxr-xr-x 5 4096 Oct 13 09:59 .. drwsr-xr-x 2 4096 Oct 13 14:15 stuff -rw-r--r-- 1 100 Oct 10 18:42 video11.txt -rw-r--r-- 1 0 Oct 9 21:16 video16.txt -rw-r--r-- 1 45 Oct 12 10:11 video19.txt -rw-r--r-- 1 149 Oct 12 16:10 video20.txt lrwxrwxrwx 1 31 Oct 13 10:11 video21.txt -> ../ridiculouslylongfilename.txt -rw-r--r-- 1 176 Oct 4 18:14 video5.txt

Ok, here, single dot . refers to this directory, double dot .. refers to directory one above. The d out front indicates that it is a directory, and l refers to the symbolic link which we set up in the last video (tutorial). Now we're getting places.

Next, make two directories within that directory using -v for that confirmation message.

$ mkdir -v stuff/morestuff stuff/extrastuff mkdir: created directory 'stuff/morestuff' mkdir: created directory 'stuff/extrastuff'

And then dive right in there using cd and ls to make sure we did it correctly.

$ cd stuff $ ls extrastuff morestuff

A Final Tip

Okay now you know how to use mkdir. And you know the syntax for commands, options and arguments.

One last tip about the mkdir command. Making directories, as you can imagine, is a very common task, as are other navigational tasks, so we'll stick with the navigation theme over the next several videos.

Okay, thanks for visiting today. I hope this was a fun introduction to the mkdir command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Here's a YouTube subscription button, if you like video tutorials to go along with the text.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the ln command, hit Back.
  • To stick with the navigational theme in our next tutorial #23 on the cp command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / mkdir command



 
 
Keywords:
linux mkdir command
mkdir command
create directory linux
mkdir command
mkdir linux
linux make directory
linux create folder
linux mkdir syntax
mkdir summary
mkdir options
mkdir tutorial
man mkdir
create directory in linux
mkdir example
mkdir unix