What is the purpose of `mkdir -p`?

QuestionsQuestions8 SkillsProPermissions of FilesAug, 15 2025
0141

The mkdir -p command is used to create directories in a Linux environment. Its purpose includes:

  1. Create Parent Directories: It allows the creation of nested directories in a single command. If any parent directory does not exist, it will be created automatically.

  2. No Error for Existing Directories: If the specified directory already exists, using -p prevents an error message from being displayed.

For example, mkdir -p new-dir/subdir will create both new-dir and subdir if they do not exist, without raising an error if they already do.

0 Comments

no data
Be the first to share your comment!