RHCSA RHCSA Linux Essentials 3 — Questions and Answers
Question 1: Which command shows all active listening TCP and UDP ports with associated process names?
- netstat -rn
- ss -tulnp (Correct answer)
- ip addr show
- nmap localhost
Correct answer: ss -tulnp
`ss -tulnp` shows TCP/UDP listening sockets with numeric addresses and the owning process.
Question 2: You need to create a 2 GiB swap file at /swapfile. What is the correct sequence?
- dd if=/dev/zero of=/swapfile bs=1M count=2048; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile (Correct answer)
- fallocate -l 2G /swapfile; mkswap /swapfile; swapon /swapfile
- dd if=/dev/zero of=/swapfile bs=1M count=2048; mkswap /swapfile; swapon /swapfile
- mkswap /swapfile 2G; chmod 600 /swapfile; swapon /swapfile
Correct answer: dd if=/dev/zero of=/swapfile bs=1M count=2048; chmod 600 /swapfile; mkswap /swapfile; swapon /swapfile
The full correct sequence creates the file, sets strict permissions (600), formats it as swap, then activates it.
Question 3: Which firewalld command permanently opens port 8080/tcp in the public zone?
- firewall-cmd --zone=public --add-port=8080/tcp
- firewall-cmd --permanent --zone=public --add-port=8080/tcp (Correct answer)
- firewall-cmd --zone=public --add-service=8080
- iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
Correct answer: firewall-cmd --permanent --zone=public --add-port=8080/tcp
The `--permanent` flag writes the rule to the zone's XML config so it persists after a reload or reboot.
Question 4: What does the `lsblk` command display?
- Loaded kernel modules
- Block device tree with mount points and sizes (Correct answer)
- Currently open file locks
- Disk partition labels only
Correct answer: Block device tree with mount points and sizes
`lsblk` lists block devices in a tree format showing name, size, type, and mount point.
Question 5: A cron job entry reads: `*/15 * * * * /script.sh`. How often does it run?
- Every 15 hours
- At minute 15 of every hour
- Every 15 minutes (Correct answer)
- 15 times per day
Correct answer: Every 15 minutes
`*/15` in the minute field means 'every 15 minutes' (0, 15, 30, 45).
Question 6: Which command would you use to restore the default SELinux context on a file?
- semanage fcontext -r /path/file
- chcon --restore /path/file
- restorecon /path/file (Correct answer)
- setsebool -P /path/file
Correct answer: restorecon /path/file
`restorecon` resets a file's SELinux context to the policy default stored in the file context database.
Question 7: What command lists all enabled systemd services that start at boot?
- systemctl list-units --type=service
- systemctl list-unit-files --type=service --state=enabled (Correct answer)
- systemctl status --all
- chkconfig --list
Correct answer: systemctl list-unit-files --type=service --state=enabled
`systemctl list-unit-files --type=service --state=enabled` shows only unit files with enabled state.
Which command shows all active listening TCP and UDP ports with associated process names?