0
0
Linux CLIscripting~20 mins

Special permissions (setuid, setgid, sticky bit) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Special Permissions Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of ls -l for a file with setuid bit set?
You run ls -l on a file with the setuid bit set. Which of the following shows the correct permission string for that file?
Linux CLI
ls -l /path/to/setuid_file
A-rwsr-xr-x 1 user group 1234 Apr 27 12:00 setuid_file
B-rwxr-sr-x 1 user group 1234 Apr 27 12:00 setuid_file
C-rwxr-xr-t 1 user group 1234 Apr 27 12:00 setuid_file
D-rwxr-xr-x 1 user group 1234 Apr 27 12:00 setuid_file
Attempts:
2 left
💡 Hint
Look for an 's' in the user execute position to indicate setuid.
💻 Command Output
intermediate
1:30remaining
What does the sticky bit do on a directory?
You set the sticky bit on a directory. What effect does it have on the directory's behavior?
Linux CLI
chmod +t /tmp/shared_dir
ls -ld /tmp/shared_dir
AOnly the directory owner, file owner, or root can delete or rename files inside the directory.
BAll users can delete or rename any files inside the directory regardless of ownership.
CThe directory becomes read-only for all users except root.
DThe directory allows execution of files inside it by all users.
Attempts:
2 left
💡 Hint
Think about shared directories like /tmp where many users write files.
📝 Syntax
advanced
1:30remaining
Which chmod command sets the setgid bit on a directory?
You want to set the setgid bit on a directory named project. Which command correctly does this?
Achmod o+s project
Bchmod +s project
Cchmod g+s project
Dchmod u+s project
Attempts:
2 left
💡 Hint
The setgid bit is related to the group permissions.
🚀 Application
advanced
1:30remaining
What is the effect of setgid on a directory's new files?
You set the setgid bit on a directory. What happens to the group ownership of new files created inside that directory?
ANew files inherit the user's primary group, ignoring the directory's group.
BNew files inherit the group ownership of the directory, not the user's primary group.
CNew files have no group ownership set.
DNew files inherit the group ownership of the parent directory's parent.
Attempts:
2 left
💡 Hint
Think about how group collaboration is managed in shared directories.
🧠 Conceptual
expert
1:30remaining
What error occurs if a non-root user tries to set the setuid bit on a file they own?
A user tries to run chmod u+s myscript.sh on a file they own but is not root. What happens?
Linux CLI
chmod u+s myscript.sh
AFile becomes unreadable due to permission conflict.
BThe setuid bit is set successfully without errors.
CSyntax error because setuid bit cannot be set with chmod.
DPermission denied error because only root can set setuid bit.
Attempts:
2 left
💡 Hint
Consider who has the privilege to set special permission bits.