Linux Permissions 5 — Questions and Answers
Question 1: What does the command 'chmod +t /shared' do?
- Sets the sticky bit on the /shared directory (Correct answer)
- Sets the setuid bit on /shared
- Grants execute permission to all users
- Makes /shared a temporary directory
Correct answer: Sets the sticky bit on the /shared directory
The +t flag in chmod sets the sticky bit on a directory, restricting file deletion to file owners only.
Question 2: Which file stores the default umask for all users on a system-wide basis on most Linux distributions?
- /etc/profile or /etc/bashrc (Correct answer)
- /etc/umask.conf
- /etc/permissions
- /proc/sys/fs/umask
Correct answer: /etc/profile or /etc/bashrc
System-wide umask settings are typically configured in /etc/profile or /etc/bashrc (or /etc/bash.bashrc on Debian-based systems).
Question 3: A directory has permissions drwxr-x---. Which users can list its contents?
- The owner and members of the directory's group (Correct answer)
- Only the owner
- All users on the system
- Only root
Correct answer: The owner and members of the directory's group
Read permission (r) on a directory allows listing its contents; both the owner (rwx) and group members (r-x) have this, but others (---) do not.
Question 4: What happens when you run chmod u=rwx,g=rx,o= file.txt?
- Owner gets rwx, group gets r-x, others get no permissions (Correct answer)
- Owner gets rwx, group gets rw-, others get r-x
- All users get rwx permissions
- Only owner gets permissions; group and others are unchanged
Correct answer: Owner gets rwx, group gets r-x, others get no permissions
The = operator sets permissions exactly; u=rwx gives owner full access, g=rx gives group read+execute, and o= removes all permissions from others.
Question 5: Which special permission bit, when set on an executable file, causes it to run with the privileges of the file's group?
- setgid bit (Correct answer)
- setuid bit
- sticky bit
- execute bit
Correct answer: setgid bit
The setgid bit on an executable causes it to run with the effective GID of the file's group rather than the caller's GID.
Question 6: What does 'ls -l' display when a file has extended ACLs in addition to standard permissions?
- A '+' sign after the permission string (Correct answer)
- An 'A' prefix before the permissions
- The word 'ACL' appended to the filename
- No visible difference in the output
Correct answer: A '+' sign after the permission string
When a file has extended ACLs, ls -l shows a '+' at the end of the permission string to indicate additional access control entries exist.
Question 7: A script file has permissions -rw-r--r--. What must be done before a user can execute it directly?
- Add execute permission with chmod +x (Correct answer)
- Change the owner to root
- Set the setuid bit
- Move it to /usr/bin
Correct answer: Add execute permission with chmod +x
A file must have the execute bit set (at minimum for the running user) before it can be executed directly as a script or binary.
What does the command 'chmod +t /shared' do?