To make a directory and any necessary parent directories, which option should be used?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Boost your Linux skills with the CompTIA Linux+ Certification Exam simulator. Engage with multiple choice questions and detailed feedback. Master Linux concepts and prepare for your exam with confidence!

Using the option to create a directory along with any necessary parent directories is crucial when you're not certain whether the desired parent directories exist. The option that facilitates this is -p. When utilized with the mkdir command, -p stands for "parents," which allows you to create the entire directory path in one command.

For example, if you wish to create a directory structure like /home/user/documents/reports, and the directories /home/user/documents do not already exist, using the command mkdir -p /home/user/documents/reports ensures that both documents and reports are created if they are not present. This is incredibly efficient and saves time compared to creating each directory individually or having to check for the existence of each parent directory first.

The other options serve different purposes: -v is used for verbose output, which provides information about what the command is doing but does not affect directory creation; -m sets the file mode (permissions) for the newly created directories, which is unrelated to creating parent directories; and -r is not a valid option for mkdir, as it's not designed for recursive operations like some other commands. This makes -p the most appropriate choice for the described task.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy