ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 335 - XK0-005 discussion

Report
Export

A systems administrator is creating new user accounts on several Linux machines and wants to automate the process from a Linux system used for operations. In this operations system, the list of servers is located in the /home/user/serverslist file and the list of user accounts is located in the /home/user/userslist file. Which of the following scripts will help accomplish this task?

A.

bash for server in $(cat /home/user/serverslist) do for user in $(cat /home/user/userslist) do sudo useradd $user done done

Answers
A.

bash for server in $(cat /home/user/serverslist) do for user in $(cat /home/user/userslist) do sudo useradd $user done done

B.

bash for server in $(cat /home/user/serverslist) do ssh -i user@$server 'for user in $(cat /home/user/userslist) do sudo useradd $user done; exit' done

Answers
B.

bash for server in $(cat /home/user/serverslist) do ssh -i user@$server 'for user in $(cat /home/user/userslist) do sudo useradd $user done; exit' done

C.

bash for server in $(cat /home/user/serverslist) do scp /home/user/userslist user@$server:/tmp ssh -i user@$server 'for user in $(cat /tmp/userslist) do sudo useradd $user done; exit' done

Answers
C.

bash for server in $(cat /home/user/serverslist) do scp /home/user/userslist user@$server:/tmp ssh -i user@$server 'for user in $(cat /tmp/userslist) do sudo useradd $user done; exit' done

D.

bash ssh user@$(cat /home/user/serverslist) 'sudo useradd $(cat /home/user/userslist); exit'

Answers
D.

bash ssh user@$(cat /home/user/serverslist) 'sudo useradd $(cat /home/user/userslist); exit'

Suggested answer: B

Explanation:

The script in option B performs the task by SSH-ing into each server listed in serverslist and then adding each user listed in userslist. This is an effective way to remotely create user accounts without manually logging into each server. The ssh command allows the execution of the useradd commands on the remote machines.

asked 09/10/2024
Andre Passos
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first