How to create a directory in Linux?
In Linux systems, directories can be created using either the command line or graphical interface.
- Create a directory using the command line.
- Open the terminal.
- To create a directory using the mkdir command, simply add the directory name after the command. For example, to create a directory named mydirectory, you would type: mkdir mydirectory.
- To create a subdirectory within an existing directory, you can use the mkdir command with the path and directory name. For example, to create a subdirectory named “mydirectory” within the /home/user/ directory, you can enter the following command: mkdir /home/user/mydirectory.
- The -p option can be used to create multiple levels of directories. For example, to create a directory at the path /home/user/documents/mydirectory, you can enter the following command: mkdir -p /home/user/documents/mydirectory.
- Create a directory using a graphic interface.
- Open a file manager such as Nautilus for GNOME desktop environment or Dolphin for KDE desktop environment.
- Navigate to the location where you want to create a directory.
- Right-click on a blank space and select “New Folder” or a similar option.
- Enter the directory name and press enter to create the directory.
Sufficient permissions are required to create a directory in the selected location, regardless of using the command line or GUI.