010-160 practice question 7 of 15
The current directory contains the following file: -rw-r—r— 1 root exec 24551 Apr 2 12:36 test.sh The file contains a valid shell script, but executing this file using ./test.sh leads to this error: bash: ./test.sh: Permission denied What should be done in order to successfully execute the script?
Full set: 81 questionsThe file's permissions are -rw-r--r--. The x (execute) bit is not set for the owner, the group, or other users. In Linux, to execute a file directly (e.g., ./test.sh), the file must have the execute permission enabled for the user attempting to run it. The error Permission denied is the direct result of this missing permission. Adding the execute bit, for example with the command chmod +x test.sh, will grant the necessary permission and allow the script to be run.
A. File extensions in Linux are primarily for user convenience and do not determine a file's executability; the permission bits do.
C. The exec group only has read permission (r--). Adding a user to this group would not grant the required execute permission.
D. The SetUID bit only works on files that are already executable. It cannot grant executability on its own.
E. The #! (shebang) is a directive used on the first line inside a script file to specify its interpreter, not as part of the command to run it.
1. GNU Coreutils Manual, chmod command: "The letters rwxXst select file mode bits for the affected users: read (r), write (w), execute (or search for directories) (x)..." This document confirms that the 'x' bit is required for execution.
Source: GNU Coreutils, Section 11.1, "chmod: Change file modes".
2. The Linux man-pages project, chmod(1): "The operator + causes the selected file mode bits to be added to the existing file mode bits of each file". This explains the mechanism for adding the execute bit.
Source: chmod(1) Linux manual page, section DESCRIPTION.
3. University of California, Berkeley, EECS Courseware: In lectures on file systems, it is established that the execute permission bit must be set for a file to be executed as a program. The absence of this bit prevents the kernel's execve() system call from succeeding, resulting in a permission error.
Source: UC Berkeley, EECS Department, CS 162: Operating Systems and Systems Programming, Lecture 12: File Systems.
Keep practicing
Take the free 010-160 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 010-160 practice questions
- Question 1What can be found in the /proc/ directory?
- Question 2Which permissions are set on a regular file once the permissions have been modified with …
- Question 3Which of the following commands puts the lines of the file data.csv into alphabetical ord…
- Question 4Which of the following programs are web servers? (Choose two.)
- Question 5The file script.sh in the current directory contains the following content: #!/bin/bash e…
- Question 6Reverse DNS assigns hostnames to IP addresses. How is the name of the IP address 198.51.1…
