None of the directories in logs/2026/08 exist.
Create the full path with one mkdir command.
Which command is appropriate?
mkdir -p creates missing parent directories before the final directory and tolerates already existing directories.
Detailed explanation
mkdir logs/2026/08Incorrect. Without -p, mkdir fails when parent directories are missing.
Incorrect. Without -p, mkdir fails when parent directories are missing.
mkdir -p logs/2026/08Correct. mkdir -p logs/2026/08 creates every missing level.
Correct. mkdir -p logs/2026/08 creates every missing level.
mkdir -m logs/2026/08Incorrect. -m sets a mode and does not replace the need for -p.
Incorrect. -m sets a mode and does not replace the need for -p.
rmdir -p logs/2026/08Incorrect. rmdir removes directories rather than creating them.
Incorrect. rmdir removes directories rather than creating them.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); mkdir -p "$tmp/logs/2026/08"; test -d "$tmp/logs/2026/08" && echo created; rm -rf "$tmp"Expected result
createdKey points
- -p means parents
- Create missing parents
- Existing directories are allowed
Notes
- Environment: GNU coreutils 9.x / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.