Directories, or folders, are organizational structures that help you organize your data and keep your Linux systems clean. They also streamline collaboration with other users on the same system.
Hence, directories become the most essential yet basic aspect for managing your systems efficiently. Creating and removing directories is a core operation, even for system administrators. However, many Linux newbies don’t know how to create new directories correctly. So, this quick tutorial explains the simple ways to create a directory in Linux. You can easily create the directories through the mkdir and File Manager. Let’s briefly take a look at both methods with suitable examples.
The mkdir Command
The sole operation of the mkdir is to create a directory, and you can use it by running the following command:
For instance, let’s create the media directory:
As you run the above command, it’ll create the media directory, and you can verify it using the ls command:
In case you want to print the output of the command, then you can use the -v option:
Moreover, if you want to create multiple directories, then all you need to do is add the name of those directories in the mkdir command:
You can also make a nested directory by using the -p option with the mkdir command:
Please replace parent_directory and sub_directory accordingly before running the command. So, let’s create the nested directory by including multiple files as the subdirectories:
You can also verify the directory using the tree command:
tree
The File Manager
Apart from using the terminal, you can opt fjyh or the File Manager to create a directory in Linux. Linux distros come with an inbuilt file manager like Nautilus. For this method, go through the following steps:
Open the File Manager and navigate to the path where you want to create the new directory.
Now, right-click and then select “New Folder” from the Options menu. In some cases, the option may show as “Create Folder.”
Finally, enter your directory’s name and press Enter.
Wrapping Up
Creating directories in Linux is the most basic task, but many beginners still need to learn how to create one. This quick tutorial focussed on providing a step-by-step method for creating a directory using the mkdir command and the File Manager. We’d recommend using the mkdir command to build familiarity with the terminal.