Which option can be used with useradd to specify the home directory for a user?

Prepare for the LPI Linux Essentials Exam with our comprehensive quiz. Study with interactive flashcards and multiple choice questions, with detailed hints and explanations for each. Ace your exam with confidence!

The option that can be used with the useradd command to specify the home directory for a user is -d. This flag allows you to define a specific path that will serve as the user's home directory when the account is created. For example, if you wanted to create a new user with a custom home directory, you would use the command like this:


useradd -d /custom/home/directory username


This ensures that the user’s files and configurations are stored in the specified directory rather than the default location, which is typically "/home/username".

The other options, while relevant in other contexts, do not serve this specific purpose. The -c option is used to add a comment, typically for a full name or description of the user; -b is for specifying the base directory for the user’s home directory (which is less specific than -d); and -h is not a standard option for useradd. Thus, -d is the correct choice for designating a user’s home directory.
Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy