If you need to use the bash terminal to create directories on Linux, the best way to do it is with the mkdir command. What is “mkdir?” It stands for “make directory,” and it’s one of the most valuable tools on all of Linux. With it, you can create folders anywhere on Linux.
There’s no need to install “mkdir” to use it on your computer. In fact, it comes pre-installed on every single Linux operating system out there today. A Linux OS probably couldn’t function without it!
Use bash to create directories – Mkdir
To create a directory on your Linux PC with the mkdir command, you will need to open up a terminal window. To open up a terminal window on the Linux desktop, press Ctrl + Alt + T on the keyboard. Or, search for “Terminal” in the app menu.
Once the terminal window is open and ready to use, execute the mkdir command below to create a new folder. For example, to make a new folder in the “home” directory (~/), you’d do the following.
Note: feel free to change (~/) to wherever you’d like to create the new folder.
mkdir ~/my_new_folder
It is also possible to use mkdir to create multiple directories at the same time in bash. For example, to create 4 folders with the names “folder_1,” “folder_2,” “folder_3,” and “folder_4,” you’d execute the following command.
mkdir folder_1 folder_2 folder_3 folder_4
To specify the locations of each of the new folders, simply add in the paths. For example, to create folder_1 in ~/
, folder_2 in ~/Documents
, folder_3 in ~/Desktop
, and folder_4 in ~/Videos
, do the following.
Note: be sure to change each of the folders’ locations to suit your own needs if you want to create multiple folders in different areas with a single command. Additionally, be sure to change the names of the folders in the command, as they are just example names.
mkdir ~/folder_1 ~/Documents/folder_2 ~/Desktop/folder_3 ~/Videos/folder_4
To delete any of your newly created folders, you can use the rm command. For example, to delete “folder_1” from the home directory (~/), enter the following command.
rm -rf ~/folder_1
For more info on how to use the mkdir command to create folders using the bash Linux terminal, execute the man mkdir command below.
man mkdir
Use bash to create directories – NNN
While the mkdir command is excellent, it isn’t the only way Linux users can create new folders using the bash terminal. It is possible to make new folders using the NNN terminal-based file manager. Here’s how.
First, you must install the NNN terminal file manager. To install it, open up a terminal window by using the Ctrl + Alt + T keyboard combination or by searching for “terminal” in the app menu.
Once the terminal window is open and ready to use, follow the installation instructions below to get NNN working.
Ubuntu
To get NNN on Ubuntu, use the Apt command.
sudo apt install nnn
Debian
To get NNN on Debian, use Apt-get.
sudo apt-get install nnn
Arch Linux
On Arch Linux, install NNN with Pacman.
sudo pacman -S nnn
Fedora
To get NNN working on Fedora, use Dnf.
sudo dnf install nnn
OpenSUSE
On OpenSUSE, NNN is installable via Zypper.
sudo zypper install nnn
Once the NNN app is installed on your computer, use the nnn command to start up the file browser. Then, use the step-by-step instructions below to use NNN to create new folders.
Step 1: In NNN, select the folder you wish to create a folder inside of. For example, to create a folder (with NNN) in the “Documents” folder, you’d select “Documents” in NNN using the Arrow keys and Enter key to select.
Step 2: Once inside the directory in which you are creating a folder, press the N key on the keyboard. By pressing N on the keyboard, you will see the following message.
'f'ile / 'd' ir / 's'ym / 'h' ard
This message lets you know your choices when pressing the N key on the keyboard. “f” for file, “d” for dir (AKA folder), “s” for symlink, and “h” for a hard link.
Step 3: Press the D key on the keyboard to tell the NNN file manager you want to create a new directory using the NNN file manager. After pressing the D key, you will see another message in NNN.
[path/]name
Type in the name of the folder into the text box. Then, press the Enter key on the keyboard to confirm it. After pressing Enter, you will see your newly created folder in NNN.