200-901 · Question #428
Refer to the exhibit. An engineer must add new users and set privileges for executing a few Python scripts. The engineer prepares a Bash script to automate this task. The script adds a user and a grou
The correct answer is A. assigning execution privileges to the owner, setting the user and group owner to the scripts that. The Bash script loop iterates over each Python script, applying chmod to grant execute permission to the owner and chown to assign the newly created user and group as the file owner.
Question
Refer to the exhibit. An engineer must add new users and set privileges for executing a few Python scripts. The engineer prepares a Bash script to automate this task. The script adds a user and a group from the command-line arguments, creates a directory, and copies the Python scripts to it. The script then changes to the directory and lists the scripts. Based on the script workflow, which process is being automated within the loop by using the list of Python scripts?
Exhibit
Options
- Aassigning execution privileges to the owner, setting the user and group owner to the scripts that
- Bcreating a file with the content of all the files, assigning execution permissions to each script, and
- Cremoving the files that are not Python, listing the Python files, and assigning execution privileges
- Dassigning execution privileges to everyone and changing the ownership to the initially created
How the community answered
(44 responses)- A80% (35)
- B11% (5)
- C7% (3)
- D2% (1)
Why each option
The Bash script loop iterates over each Python script, applying chmod to grant execute permission to the owner and chown to assign the newly created user and group as the file owner.
Within the loop, a chmod command such as 'chmod u+x' grants execution privileges exclusively to the owning user, and a chown command sets the user and group ownership of each script to the user and group created from the command-line arguments - directly matching the described per-script privilege and ownership workflow.
Concatenating file contents into a new file is not part of the described script logic, which copies pre-existing Python scripts into the target directory rather than merging them.
Removing non-Python files contradicts the script's workflow, which copies only Python scripts into the directory and performs no deletion or filtering operations.
Assigning execution privileges to all users (e.g., chmod a+x) rather than only the owner conflicts with the script's goal of setting targeted privileges for the specific user created at the start of the script.
Concept tested: Bash automation of Linux chmod and chown per file
Source: https://linux.die.net/man/1/chmod
Topics
Community Discussion
No community discussion yet for this question.
