200-901 Question 163
Select 3As a network automation engineer, you are tasked with managing users and directories on a Linux-based server that hosts your Python scripts. You need to create a new user named 'devnet_user', assign them a home directory at '/home/devnet_user', and verify their access to the directory. Which of the following steps would you take to achieve this?
- A
Use the command
sudo useradd -m -d /home/devnet_user devnet_userto create the user and their home directory. - B
Use the command
sudo mkdir /home/devnet_userto manually create the directory before adding the user. - C
Verify the user's home directory permissions using the command
ls -ld /home/devnet_user. - D
Assign a password to the user using the command
sudo passwd devnet_user. - E
Use the command
sudo userdel -r devnet_userto create the user and their home directory.
Show answer and explanation
Correct answers: A, C, D
Explanation
To manage users and directories in a Linux server, you can use the useradd command with appropriate flags to create a user and their home directory. After creation, it is essential to verify the permissions of the home directory to ensure the user has appropriate access. Additionally, assigning a password to the user is mandatory for enabling login. Manual directory creation or using commands meant for user deletion is not required in this scenario.
- A. Correct.
Correct: The
useraddcommand with the-mand-doptions will create the user, generate their home directory, and assign the specified path as the home directory. - B. Incorrect.
Incorrect: Manually creating the directory is unnecessary since the
useraddcommand with the-moption automatically creates the home directory. - C. Correct.
Correct: The
ls -ldcommand is a valid way to verify the permissions and ownership of the user's home directory. - D. Correct.
Correct: The
passwdcommand is necessary to set or update the password for the newly created user, enabling them to log in. - E. Incorrect.
Incorrect: The
userdelcommand is used to delete a user, not to create one. Using this command would remove the user and their home directory if it existed.