Linux System Administration 3 — Questions and Answers
Question 1: Which command would you use to add a user to a supplementary group without changing their primary group?
- usermod -g groupname username
- usermod -aG groupname username (Correct answer)
- groupadd -u username groupname
- adduser --group groupname username
Correct answer: usermod -aG groupname username
`usermod -aG` appends the user to the specified group while preserving existing group memberships.
Question 2: What is the effect of setting the SUID bit on an executable file?
- The file runs with the permissions of the group owner
- The file runs with the permissions of the file owner (Correct answer)
- The file is shared among all users
- The file cannot be deleted by non-owners
Correct answer: The file runs with the permissions of the file owner
SUID (Set User ID) causes the executable to run with the privileges of the file's owner, not the user who runs it.
Question 3: You need to schedule a one-time task to run at 3:30 PM today. Which command is correct?
- cron -t '15:30'
- at 3:30pm (Correct answer)
- schedule 15:30 today
- crontab -e 15:30
Correct answer: at 3:30pm
The `at` command schedules a one-time task at a specified time, unlike `cron` which handles recurring tasks.
Question 4: Which `/proc` entry shows the currently loaded kernel modules?
- /proc/modules (Correct answer)
- /proc/kmods
- /proc/drivers
- /proc/kconfig
Correct answer: /proc/modules
`/proc/modules` lists all currently loaded kernel modules, equivalent to the output of `lsmod`.
Question 5: What does `journalctl --since '1 hour ago'` do?
- Shows journal entries from exactly one hour ago only
- Shows all journal entries from the last hour until now (Correct answer)
- Deletes journal entries older than one hour
- Exports one hour of logs to a file
Correct answer: Shows all journal entries from the last hour until now
`--since` filters journal output to show entries from the specified time to the present.
Question 6: A disk partition shows 100% usage but `df -h` reports only 80% used. What is the most likely cause?
- The filesystem needs defragmentation
- Reserved blocks for root are consuming space (Correct answer)
- The partition table is corrupted
- Symbolic links are inflating the count
Correct answer: Reserved blocks for root are consuming space
ext2/3/4 filesystems reserve 5% of space for the root user by default, which doesn't show in regular `df` output.
Question 7: Which command shows which package owns a specific file on a Debian-based system?
- apt-file search /path/to/file
- dpkg -S /path/to/file (Correct answer)
- apt show /path/to/file
- dpkg -L /path/to/file
Correct answer: dpkg -S /path/to/file
`dpkg -S` searches the dpkg database to find which installed package owns a given file path.
Which command would you use to add a user to a supplementary group without changing their primary group?