Back to sections

Linux Quiz

Test what you actually know about Linux. Free sample questions below, from easy to hard, with instant explanations.

easy

1. What does chmod 600 ~/.ssh/id_rsa enforce?

Owner can execute; group can read
All users can read
Owner can read/write; group/others have no accessCorrect
File is immutable

600 breaks down as: owner gets read and write, and literally everyone else (group, other) gets nothing at all. SSH actually enforces this for private keys specifically, it will flat-out refuse to use a key file that's readable by anyone besides its owner.

medium

2. A high-traffic Nginx server exhausts ephemeral ports (32768–60999). Which two kernel tunables fix this?

All of the aboveCorrect
net.ipv4.tcp_fin_timeout = 15
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1

These three settings attack the same problem from different angles: widening the ephemeral port range gives you a bigger pool of ports to use for outgoing connections, shortening tcp_fin_timeout means closed sockets don't linger in TIME_WAIT as long, and tcp_tw_reuse lets the kernel recycle those TIME_WAIT sockets for new connections sooner. Together, they meaningfully relieve port exhaustion under high connection churn.

hard

3. After rotating SSH host keys across a fleet, every connection now prompts a host key warning. Rather than disabling StrictHostKeyChecking fleet-wide, what's the more security-conscious fix?

Set StrictHostKeyChecking=no globally in ssh_config
Distribute the updated known_hosts entries via configuration management, or move to SSH certificates signed by a trusted CACorrect
Delete each user's known_hosts file before every connection via a script
Switch all servers to password authentication instead

Host key warnings exist specifically to protect you from man-in-the-middle attacks, so turning that checking off everywhere throws away the exact protection host keys provide. Pushing the correct, updated known_hosts entries out to everyone (or moving to CA-signed SSH certificates) fixes the warnings without giving up that protection.

easy

4. The /tmp directory typically shows permissions like `drwxrwxrwt`. What does the trailing `t` (sticky bit) actually restrict?

Only root can create new files in the directory.
Only the file's owner (or root) can delete or rename a file within that directory, even though everyone can write there.Correct
Files created in the directory automatically inherit the directory's group instead of the creator's primary group.
The directory's contents are cached in memory and never written to disk.

The sticky bit on a world-writable directory like /tmp stops one user from deleting or renaming another user's files, even though the permissive rwx would otherwise allow it. Without it, anyone with write access to the directory could remove files they don't own, which would make a shared temp directory unsafe. Option B describes the setgid bit on a directory instead, a completely different permission bit.

medium

5. One specific user intermittently loses access to an NFS-mounted directory, with the terminal appearing to hang. What's the right first diagnostic step?

Check dmesg/journalctl for NFS timeout or server-not-responding messagesCorrect
Delete the user's home directory and recreate it
Restart the entire server immediately
Disable NFS for that mount permanently

NFS connectivity problems and timeouts are typically recorded directly in the kernel's own log (dmesg/journalctl), which is exactly where you'd look first to understand what's actually happening. Jumping straight to deleting the user's home directory or restarting the whole server skips real diagnosis entirely and risks losing data for no reason.

hard

6. An application needs a higher open-file-descriptor limit permanently, not just for the current shell session. Why doesn't running `ulimit -n 65536` at the shell solve this properly, and what's the correct fix?

ulimit set that way only affects the current shell and its children; persist it via /etc/security/limits.conf (or a drop-in under limits.d/) insteadCorrect
File descriptor limits cannot be changed on Linux at all
The correct fix is always to recompile the kernel with new defaults
ulimit -n is deprecated and no longer works on any modern distro

Running ulimit interactively only changes the limit for THAT shell session and whatever it spawns afterward, it's completely forgotten the moment you log out or reboot. To make a higher file-descriptor limit stick permanently for a user or service, it needs to be configured in limits.conf (or the equivalent systemd setting for a service), not set ad hoc in a terminal.

easy

7. Before starting your own service on port 8080, you need to confirm nothing else is already listening on it. Which command answers this directly?

ls -la /dev/8080
ps aux | grep 8080
top
ss -tlnp | grep 8080Correct

ss -tlnp lists exactly what you need in one shot: every TCP socket currently listening, and which process owns it, so you can immediately see if port 8080 is already taken before you try to bind your own service to it.

medium

8. Why does dd if=/dev/zero of=test bs=1M count=1024 show higher speed than real disk writes?

Writes go to page cache (not disk) → sync forces flushCorrect
dd uses async I/O
/dev/zero is compressed
Disk write-back caching

dd's writes don't go straight to the physical disk, they land in the page cache (RAM) first, and the command returns as soon as they're buffered there, not once they've actually hit the platter. That's why the reported speed looks suspiciously fast, it's really measuring RAM bandwidth, and only an explicit sync afterward forces those buffered writes out to real disk.

hard

9. A process is stuck in D state (uninterruptible sleep) and doesn't respond even to `kill -9`. What does this most likely indicate, and what's the correct next step?

The correct fix is always an immediate hard reboot with no further diagnosis
The process is a zombie and can be safely ignored
The process is blocked on I/O (e.g. a hung NFS mount or failing disk) - investigate the underlying storage/network issue via dmesg and related logsCorrect
kill -9 is simply broken on this system and needs a reinstall

D state means the process is stuck waiting on the kernel for an I/O operation to finish, and that wait genuinely cannot be interrupted, not even by a kill -9. The real problem is whatever it's stuck waiting ON (a hung NFS server, a failing disk), so the fix is digging into logs like dmesg to find and address that underlying issue, not fighting the stuck process itself.

easy

10. You run `ls -l script.sh` and see `-rw-r--r--`. Running `./script.sh` fails with 'Permission denied.' What's the most direct fix?

chown $(whoami) script.sh
chmod +x script.shCorrect
sudo ./script.sh
mv script.sh script

The permissions shown (rw-r--r--) simply never included execute for anyone, that's the whole problem. You already own the file, so chown changes nothing, and sudo just runs the command as root, it doesn't add an execute bit, the script still needs one to be runnable at all, which is exactly what chmod +x adds.

Ready for the real thing?

Take the full timed Linux quiz and see your score.

    Welcome to OpsQuiz!

    Real scenario-based DevOps questions, hands-on practice, and clear explanations for every answer.