XK0-006 · Question #131
A Linux administrator needs to create accounts for a list of new users. The user account names have been defined in the user LIST variable by executing the following: USER_LIST="alice bob charles"…
The correct answer is D. for username in $USER_LIST; do useradd -m "$username"; done. This command iterates over each username stored in the variable and executes the account creation command for each entry, which is the correct and reliable way to create multiple user accounts from a list in a shell script.
Question
A Linux administrator needs to create accounts for a list of new users. The user account names have been defined in the user LIST variable by executing the following:
USER_LIST="alice bob charles" Which of the following commands should the administrator use to successfully create the user accounts?
Options
- Aecho "$USER LIST" | while username; do useradd -m "$username"; done
- Becho "$USER_LIST" | until username; do useradd -m "$username"; done
- Cselect username in "$USER_LIST"; do useradd -m $username"; done
- Dfor username in $USER_LIST; do useradd -m "$username"; done
How the community answered
(36 responses)- A3% (1)
- C6% (2)
- D92% (33)
Explanation
This command iterates over each username stored in the variable and executes the account creation command for each entry, which is the correct and reliable way to create multiple user accounts from a list in a shell script.
Topics
Community Discussion
No community discussion yet for this question.