How to Make a New Directory in Linux

By Techwalla Contributor

Use the BASH (Bourne-Again SHell) command 'mkdir' to create a new directory in Linux for keeping your files and your hard drive organized. Each directory can have its own parameters attached, such as access, modification and removal permissions. "Mkdir" is one of the more important BASH commands used in Linux; you can use it to make a new directory whenever needed.

Things You'll Need

  • BASH

Step 1

Check the currently active directory before using the "mkdir" command. This will eliminate errors later if you are using a directory in which you don't have such command privileges. You can check this by using the "pwd" command and pressing "Enter."

Step 2

Type "mkdir [directory]" at the command prompt to make the directory. Use the name of your new directory in place of the [directory] command line operator. For example, to create a directory called "business," type "mkdir business." Be aware that this will create the directory within the current working directory.

Step 3

Use the "-p" command line parameter to create subdirectories within a parent directory. For example, type "mkdir -p games/strategy/chess" to create a directory tree including "strategy/chess" within the "games" directory.

Step 4

Create a new directory in a directory other than the current working directory using the "-p" command line parameter as you did to create a directory tree. In this situation always include the slash "/" before the first directory's name. In other words, if you wanted to create a "chess" directory in a "games" directory that already exists you would type "mkdir -p /games/chess."

Step 5

Make multiple directories at once using the "mkdir" command. Do this by including a space in between each of the directories you intend to create. For example, the command "mkdir -p games bin lib personal" would create "games," "bin," "lib" and "personal" directories all at once.

Tips & Warnings

  • Every major user interface includes a function for making a new directory without the need for the BASH console. You can make a directory using menu options and mouse clicks instead of the more complex "mkdir" command line.
  • You can only make a new directory in a directory in which you have access. You cannot make a new directory in someone else's domain. Root users may make a new directory anywhere within Linux using "mkdir."
  • Always watch your spelling when using the "mkdir" command. Misspelling directories can make them difficult to locate or navigate to later.