Linux System Administration 4 — Questions and Answers
Question 1: What is the purpose of the `/etc/hosts.allow` and `/etc/hosts.deny` files?
- Control DNS resolution order
- Define TCP Wrappers access control rules (Correct answer)
- Set firewall port forwarding rules
- Configure SSH known hosts
Correct answer: Define TCP Wrappers access control rules
TCP Wrappers reads `/etc/hosts.allow` and `/etc/hosts.deny` to permit or block connections to wrapped services.
Question 2: Which command would display all open network ports and the processes listening on them?
- netstat -tulpn (Correct answer)
- ifconfig -a
- ip route show
- lsof -i -n
Correct answer: netstat -tulpn
`netstat -tulpn` shows TCP/UDP listening ports with the process name/PID (requires root for all processes).
Question 3: You want to find all files modified in the last 24 hours under `/var/log`. Which command is correct?
- find /var/log -mtime -1 (Correct answer)
- find /var/log -mtime 1
- find /var/log -newer 24
- ls -lt /var/log | head
Correct answer: find /var/log -mtime -1
`-mtime -1` matches files modified less than 1 day (24 hours) ago; the minus sign means 'less than'.
Question 4: What is the primary function of `logrotate`?
- Encrypts log files after they reach a size limit
- Manages automatic rotation, compression, and deletion of log files (Correct answer)
- Streams logs to a remote syslog server
- Indexes logs for faster searching
Correct answer: Manages automatic rotation, compression, and deletion of log files
`logrotate` automatically rotates, compresses, removes, and mails log files based on rules in `/etc/logrotate.conf`.
Question 5: Which `iptables` chain filters packets destined for the local system?
- FORWARD
- OUTPUT
- INPUT (Correct answer)
- PREROUTING
Correct answer: INPUT
The INPUT chain processes packets destined for the local machine's own network stack.
Question 6: What does the `lsblk` command display?
- List of blocked system calls
- Block device tree showing disks and partitions (Correct answer)
- Lock status of filesystem blocks
- List of bad blocks on a disk
Correct answer: Block device tree showing disks and partitions
`lsblk` lists block devices in a tree format showing disks, partitions, and their mount points.
Question 7: A service fails to start and you see 'Unit not found'. What is the most likely cause?
- The service is masked
- The unit file does not exist or is not in the search path (Correct answer)
- The service requires manual start only
- The systemd daemon needs reloading
Correct answer: The unit file does not exist or is not in the search path
'Unit not found' means systemd cannot locate the service's unit file in any of its configured directories.
What is the purpose of the `/etc/hosts.allow` and `/etc/hosts.deny` files?