Given the file -rwxr-xr-x 1 root root 859688 Feb 7 08:15 test.sh, how can this script be executed? (Choose two.)

Prepare for the LPI Linux Essentials 010-160 Test. Study with flashcards and multiple choice questions, each question offers hints and explanations. Get ready to ace your exam!

The file permissions for "test.sh" indicate that it is a script that is executable by the owner (root) and readable by others. To execute this script, there are several methods available, two of which are valid in this scenario.

Executing the script directly with ./test.sh is one of the correct methods. The prefix ./ specifies that the script should be executed from the current directory. This is essential because, for security reasons, the shell does not include the current directory in the search path by default when looking for executables. Therefore, using ./ indicates to the shell that it should look for the file in the current directory.

The method using bash test.sh is also valid as it explicitly invokes the Bash shell to run the script. When you invoke a script this way, you are using the bash command to interpret the script. This is a standard way to run any script as long as the right shell (in this case, Bash) is specified.

These methods correctly utilize the permissions set on the file and the current context to execute the shell script.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy