Linux System Administration 2 — Questions and Answers
Question 1: Which command displays the current runlevel on a systemd-based Linux system?
- runlevel
- systemctl get-default
- who -r (Correct answer)
- init --status
Correct answer: who -r
The `who -r` command displays the current runlevel on both SysV and systemd systems.
Question 2: What does the `/etc/fstab` file control?
- Firewall rules for mounted filesystems
- Filesystem mount points and options at boot (Correct answer)
- File permission defaults for new files
- Swap partition encryption keys
Correct answer: Filesystem mount points and options at boot
The `/etc/fstab` file defines how disk partitions and filesystems are mounted automatically at boot.
Question 3: Which `systemctl` subcommand prevents a service from starting automatically at boot without stopping it if currently running?
- systemctl stop
- systemctl mask
- systemctl disable (Correct answer)
- systemctl deactivate
Correct answer: systemctl disable
`systemctl disable` removes the service from startup targets without affecting its current running state.
Question 4: A system has 4GB RAM and no swap. What is the recommended swap size according to Red Hat guidelines for hibernation support?
- 2GB
- 4GB
- 8GB (Correct answer)
- 16GB
Correct answer: 8GB
Red Hat recommends swap equal to RAM + square root of RAM for hibernation; for 4GB RAM that rounds up to 8GB.
Question 5: What is the purpose of the `nice` command in Linux?
- Set file ACL permissions
- Adjust process scheduling priority (Correct answer)
- Rename files with friendly names
- Send SIGNICE signal to processes
Correct answer: Adjust process scheduling priority
`nice` launches a command with a modified scheduling priority (niceness value from -20 to 19).
Question 6: Which log file on a systemd system would you query to see kernel boot messages?
- /var/log/boot.log
- /var/log/kern.log
- journalctl -k (Correct answer)
- /proc/kmsg
Correct answer: journalctl -k
`journalctl -k` (or `--dmesg`) displays kernel messages from the current boot stored in the systemd journal.
Question 7: What does the `umask 022` setting mean for a newly created file?
- Files are created with permissions 022
- Files are created with permissions 644 (Correct answer)
- Files are created with permissions 755
- Files are created with permissions 600
Correct answer: Files are created with permissions 644
Default file permissions (666) minus umask (022) results in 644 (rw-r--r--) for new files.
Which command displays the current runlevel on a systemd-based Linux system?