How to Make a New Directory in Linux
Directories are an important component of keeping your files and your hard drive organized in Linux. Each directory can have its own parameters attached, such as who has access to it, who can modify it and even who has permission to remove it. One of the more important BASH (Bourne-Again SHell) commands used in Linux is the "mkdir" command, which is used to make a new directory whenever needed.
Instructions
-
-
1
Check which directory you are currently active in prior to using the "mkdir" command. This will eliminate errors later if you are in a directory in which you don't have such command privileges. You can check this by using the "pwd" command and pressing "Enter."
-
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. To create a directory called "business," you would type "mkdir business." Be aware that this will create the directory within the current working directory.
-
-
3
Use the "-p" command line parameter to create subdirectories within a parent directory. For example, you would type "mkdir -p games/strategy/chess" to create a directory tree including "strategy/chess" within the "games" directory.
-
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 manner however, it is important to include the slash "/" prior to 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."
-
5
Make multiple directories at once using the "mkdir" command. You can 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 a "games," "bin," "lib" and "personal" directory all at once.
-
1
Tips & Warnings
Be aware that every major GUI (graphical user interface) includes a function needed to make a new directory without having to use the BASH console. You can make a directory using menu options and mouse clicks instead of the more complex "mkdir" command line.
Be aware that 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 be careful about spelling when you use the "mkdir" command. Misspelling directories can make them difficult to locate or navigate to later.