How do I create a new directory?

QuestionsQuestions8 SkillsProBasic Files OperationsSep, 14 2025
0139

To create a new directory in a Linux terminal, you can use the mkdir command. Here’s how to do it step-by-step:

Steps to Create a New Directory:

  1. Open Terminal: Access your terminal application.

  2. Use the mkdir Command: Type the following command to create a new directory:

    mkdir directory_name

    Replace directory_name with the desired name for your new directory.

Example:

If you want to create a directory named my_folder, you would run:

mkdir my_folder

Creating a Directory in a Specific Location:

If you want to create a directory in a specific path (e.g., in your home directory), you can specify the full path:

mkdir /home/your_username/my_folder

Replace your_username with your actual username.

Creating Parent Directories:

If you want to create a directory along with its parent directories (if they don’t exist), use the -p option:

mkdir -p /home/your_username/new_folder/sub_folder

This command will create new_folder and sub_folder if they do not already exist.

Verify Creation:

After creating the directory, you can verify it by listing the contents of the parent directory:

ls

This will show you the newly created directory in the list.

If you have any further questions or need assistance with a specific scenario, feel free to ask!

0 Comments

no data
Be the first to share your comment!