To create new directories in Linux, you use the mkdir command, which stands for "make directory."
Here are the most common ways to use it:
1. Create a single directory
To create a folder named "notes" in your current location, type:
mkdir notes
2. Create multiple directories at once
You can create several folders with one command by separating the names with spaces:
mkdir docs images backups
3. Create nested directories (Parent-Child)
If you want to create a folder inside another folder that doesn't exist yet (like photos/vacation), use the -p (parents) flag:
mkdir -p photos/vacation
This tells Linux: "Make the photos folder first, then make the vacation folder inside it."
4. Verify your new directory
After creating a directory, you can use the ls command to see it:
ls
You will see your new folder listed in the output.
Try it now!
- Make sure you are in your project folder:
cd /home/labex/project - Create a folder:
mkdir my_new_folder - Check if it's there:
ls