FactorPad
Build a Better Process

Linux mkdir Command Summary with Examples

Linux 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.
face pic by Paul Alan Davis, CFA
Updated: February 23, 2021
In this tutorial on Linux mkdir, 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 Tip Next

/ factorpad.com / tech / linux-essentials / mkdir-command.html


An ad-free and cookie-free website.


Examples of the Linux mkdir Command

Beginner

Learn to make directories at the Linux command line.

Video Tutorial

Videos can also be accessed from the Linux Essentials Playlist on YouTube.

Linux mkdir Command Summary with Examples (3:30)

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.

Common Linux mkdir Options
-options description
--help Print help screen
-m, --mode=MODE Set directory mode (permissions)
-v, --verbose Print a confirmation message

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?

If you learned something today, a good way to give back is to make a link to factorpad.com on your website. Also, for reminders of new content there are three ways to connect, YouTube, Twitter and through our no-spam email list.

Outline Back Tip Next

/ factorpad.com / tech / linux-essentials / mkdir-command.html


linux mkdir command
mkdir linux
mkdir command
create directory linux
create directory linux
mkdir linux
linux make directory
linux make directory examples
linux create folder
linux mkdir syntax
mkdir summary
mkdir options
linux mkdir examples
mkdir tutorial
man mkdir
create directory in linux
mkdir example

A newly-updated free resource. Connect and refer a friend today.