QuestionQ305

Infrastructure and Automation

Question Image

Refer to the exhibit. An engineer needs to add new users and configure privileges to execute several Python scripts. The engineer creates a Bash script to automate this work. The script adds a user and a group from command-line arguments, creates a directory, and copies the Python scripts into it. It then changes to that directory and lists the scripts. Based on this script workflow, which process is automated within the loop by using the list of Python scripts?

  • A assigning execution privileges to the owner, setting the user and group owner to the scripts that were initially created, and storing the script names in a file.
  • B creating a file with the content of all the files, assigning execution permissions to each script, and then changing ownership to the initially created user and group.
  • C removing the files that are not Python, listing the Python files, and assigning execution privileges to the initially created user and group.
  • D assigning execution privileges to everyone and changing the ownership to the initially created user and group.
Explanation

For every listed Python script, echo $file >> content.txt appends its name to content.txt; chmod u+x $file adds execute permission for the file owner; and chown $1:$2 $file changes the script’s user and group ownership to the user and group supplied as arguments. In symbolic permission modes, u denotes the file owner and x denotes execute permission; chown owner:group changes both ownership fields.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!