The mkdir -p command is used to create directories in a Linux environment. Its purpose includes:
-
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.
-
No Error for Existing Directories: If the specified directory already exists, using
-pprevents 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.
