New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

LPI 010-160 Exam - Topic 1 Question 58 Discussion

Actual exam question for LPI's 010-160 exam
Question #: 58
Topic #: 1
[All 010-160 Questions]

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?

Show Suggested Answer Hide Answer
Suggested Answer: B

The execute bit in Linux is a permission bit that allows the user to run an executable file or enter a directory. For regular files, such as scripts or binaries, the execute bit must be set for the user to run them. For directories, the execute bit allows the user to access the files and subdirectories inside. Therefore, to successfully execute the script test.sh, the execute bit should be set in the file's permissions. This can be done by using the chmod command with the +x option, for example: chmod +x test.sh. The other options are either irrelevant or incorrect. The file's extension does not affect its executability, only its association with a program. The user executing the script does not need to be in the exec group, as long as the user has the execute permission on the file. The SetUID bit is a special permission bit that allows the user to run the file as the file's owner, regardless of the user's identity. This is not necessary for executing the script, and may pose a security risk. The #!./test.sh syntax is invalid, as the #! is used to specify the interpreter for the script, not the script itself.Reference:

Linux Essentials Version 1.6 Objectives1, Topic 1.4: Command Line Basics, Subtopic: Basic Shell Commands

Linux Essentials Version 1.6 Exam Preparation Guide2, Section 1.4: Command Line Basics, Page 16

Execute vs Read bit.How do directory permissions in Linux work?3


Contribute your Thoughts:

0/2000 characters
Paz
8 hours ago
Wait, why would you use #!./test.sh? That's just odd.
upvoted 0 times
...
Salome
5 days ago
Changing the extension won't help, A is wrong.
upvoted 0 times
...
Edgar
11 days ago
Totally agree, B is the way to go!
upvoted 0 times
...
Becky
16 days ago
Just need to set the execute bit, that's B!
upvoted 0 times
...
Layla
21 days ago
E) The script should be run using #!./test. sh instead of ./test.sh.
upvoted 0 times
...
Cora
26 days ago
Duh, it's obviously the execute bit. How else are you supposed to run a script?
upvoted 0 times
...
Sharita
1 month ago
B) The execute bit should be set in the file's permissions.
upvoted 0 times
...
Vanesa
1 month ago
I vaguely recall that the SetUID bit is more for running scripts with elevated privileges, so I don't think that's the right answer here.
upvoted 0 times
...
Donette
1 month ago
I practiced a question similar to this, and I think adding the user to the exec group might not be necessary if we can just change the permissions.
upvoted 0 times
...
Holley
2 months ago
I'm not entirely sure, but I feel like changing the file extension isn't going to help with the permission issue.
upvoted 0 times
...
Nan
2 months ago
I remember something about file permissions, and I think we need to set the execute bit for the script to run it.
upvoted 0 times
...
Lorriane
2 months ago
The question seems straightforward - the execute bit is missing, so I'll choose option B to fix that.
upvoted 0 times
...
Eric
2 months ago
I'm leaning towards option B as well. The error message indicates a permissions issue, so setting the execute bit seems like the right approach.
upvoted 0 times
...
Socorro
2 months ago
Okay, I know the execute bit needs to be set, so I'll go with option B. That should let me run the script successfully.
upvoted 0 times
...
Santos
2 months ago
I think B is the right choice.
upvoted 0 times
...
Glory
3 months ago
A doesn't make sense. Changing the extension?
upvoted 0 times
...
Herminia
3 months ago
Haha, someone forgot to make the script executable. Classic UNIX mistake!
upvoted 0 times
...
Elza
3 months ago
Hmm, I'm a bit confused. I'm not sure if changing the extension or setting the SetUID bit would work here.
upvoted 0 times
...
Billy
3 months ago
I think the issue is with the file permissions, so I'll try option B and set the execute bit.
upvoted 0 times
...

Save Cancel