How to create parent directories?

QuestionsQuestions8 SkillsProBasic Files OperationsDec, 03 2025
063

To create parent directories in one command, you can use the mkdir command with the -p option. This allows you to create a hierarchy of directories, including any necessary parent directories that do not already exist.

Command:

mkdir -p /path/to/parent/directory/new_directory

Example:

If you want to create a directory structure like /home/labex/project/subdir, you would run:

mkdir -p /home/labex/project/subdir

Explanation:

  • -p: This option tells mkdir to create parent directories as needed.
  • /home/labex/project/subdir: This is the full path where you want to create the new directory.

Feel free to ask if you have more questions!

0 Comments

no data
Be the first to share your comment!