Exam 010-160 Topic 2 Question 46 Discussion
Actual exam question for Lpi's 010-160 exam
Question #: 46
Topic #: 2
Question #: 46
Topic #: 2
The current directory contains the following file:
-rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh
Given that the file is a valid shell script, how can this script be executed? (Choose two correct answers.)
-rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh
Given that the file is a valid shell script, how can this script be executed? (Choose two correct answers.)
Suggested Answer: D,E Vote an answer
A shell script is a file that contains a series of commands that can be executed by a shell interpreter. To execute a shell script, there are two main methods:
Method 1: Specify the path to the script file. This method requires that the script file has the execute permission, which can be granted by using the chmod command. The script file also needs to have a shebang line at the beginning, which indicates which interpreter to use for the script. For example, #!/bin/bash means to use the bash interpreter. To execute the script using this method, you can type the absolute path or the relative path to the script file. If you are in the same directory as the script file, you can use the ./ prefix to indicate the current directory. For example, ./test.sh will execute the test.sh script in the current directory.
Method 2: Pass the script file as an argument to the interpreter. This method does not require the execute permission or the shebang line for the script file. You can simply use the name of the interpreter followed by the script file name as an argument. For example, bash test.sh will execute the test.sh script using the bash interpreter.
Therefore, the correct answers are D and E. A. run test.sh is incorrect because run is not a valid command in Linux. B. ${test.sh} is incorrect because this syntax is used for variable expansion, not for executing a script. C. cmd ./test.sh is incorrect because cmd is not a valid command in Linux. Reference:
Linux Essentials Topic 105: The Power of the Command Line, section 105.3: Basic shell scripting.
How to Run a Shell Script in Linux [Essentials Explained] - It's FOSS
How To Execute a Command with a Shell Script in Linux | DigitalOcean
How To Run the .sh File Shell Script In Linux / UNIX
Method 1: Specify the path to the script file. This method requires that the script file has the execute permission, which can be granted by using the chmod command. The script file also needs to have a shebang line at the beginning, which indicates which interpreter to use for the script. For example, #!/bin/bash means to use the bash interpreter. To execute the script using this method, you can type the absolute path or the relative path to the script file. If you are in the same directory as the script file, you can use the ./ prefix to indicate the current directory. For example, ./test.sh will execute the test.sh script in the current directory.
Method 2: Pass the script file as an argument to the interpreter. This method does not require the execute permission or the shebang line for the script file. You can simply use the name of the interpreter followed by the script file name as an argument. For example, bash test.sh will execute the test.sh script using the bash interpreter.
Therefore, the correct answers are D and E. A. run test.sh is incorrect because run is not a valid command in Linux. B. ${test.sh} is incorrect because this syntax is used for variable expansion, not for executing a script. C. cmd ./test.sh is incorrect because cmd is not a valid command in Linux. Reference:
Linux Essentials Topic 105: The Power of the Command Line, section 105.3: Basic shell scripting.
How to Run a Shell Script in Linux [Essentials Explained] - It's FOSS
How To Execute a Command with a Shell Script in Linux | DigitalOcean
How To Run the .sh File Shell Script In Linux / UNIX
by Edmund at Mar 03, 2026, 12:42 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).