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. A support engineer needs to quickly find every line mentioning 'connection refused' inside a 50,000-line application log file. What's the simplest tool for this?

systemctl
chmod
grepCorrect
cron

grep searches text for lines matching a pattern, so grep 'connection refused' app.log instantly pulls out every matching line, even from huge files. chmod changes file permissions, cron schedules tasks, and systemctl manages services, none of which search file contents.

medium

2. A script works fine when an engineer runs it manually from their terminal, but the same script fails silently when triggered by cron. What's the most common cause?

Cron runs jobs with a much more limited environment and PATH than an interactive shellCorrect
The script's file extension must be .cron
Cron jobs can only run scripts written in Python
Cron does not support scripts longer than 50 lines

Cron executes jobs with a minimal environment, often missing the PATH and other environment variables that are normally set up in an interactive login shell, so commands the script assumes are available may not be found. The fix is usually to use full paths to commands or explicitly set the needed environment variables inside the script. The other options describe limitations that don't actually exist in cron.

hard

3. What does echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled do?

Disables all BPF
Enables BPF JIT
Restricts tcpdump
Prevents unprivileged users from loading eBPF programs (mitigates privilege escalation)Correct

This specific sysctl is a targeted security switch: setting it to 1 stops regular, non-root users from loading their own eBPF programs into the kernel. That matters because eBPF's verifier has historically been a target for privilege-escalation exploits, so closing that door to unprivileged users removes a whole class of attack, without disabling BPF entirely for root or authorized processes.

easy

4. A shell script needs to reference the current user's home directory without hardcoding a path like /home/alice, so it works for any user. What should it use?

The /root directory
The $HOME environment variableCorrect
A hard link to the home folder
The PID of the shell

$HOME is an environment variable that always points to the current user's home directory, so scripts using it work correctly no matter who runs them. /root is specifically the home directory of the root user only, and a hard link or process ID have nothing to do with finding a user's home folder.

medium

5. An engineer sets up SSH key based login to a new server, but connecting still prompts for a password instead of using the key. On the server, `ls -l ~/.ssh/authorized_keys` shows permissions of `-rw-rw-rw-`. What's the likely problem?

SSH refuses to trust authorized_keys because its permissions are too openCorrect
The public key was pasted in the wrong font
The server's clock is set to the wrong timezone
SSH keys expire after 24 hours by default

SSH deliberately refuses to use an authorized_keys file (or .ssh directory) that is writable by other users or groups, since that would let anyone tamper with which keys are trusted. Permissions of -rw-rw-rw- are far too permissive; it should typically be 600 (readable and writable only by the owner). Fonts, timezones, and key expiration aren't real factors here.

hard

6. A web app's file contexts (`ls -Z`) look correct, but it's still blocked from making outbound database connections under SELinux enforcing mode. What's the correct type of fix?

Add another file context rule with semanage fcontext
Relabel the entire filesystem with fixfiles
Toggle the relevant SELinux boolean, e.g. setsebool -P httpd_can_network_connect onCorrect
Re-run restorecon on the application directory again

File labels (what ls -Z shows) control access to files and directories specifically, they have nothing to do with whether a process is allowed to make NETWORK connections. That separate behavior is governed by SELinux booleans, and something like httpd_can_network_connect being off by default is exactly what would block outbound database connections even when every file is labeled correctly.

easy

7. Which command lists all block devices (including LVM, NVMe, loop)?

df -h
fdisk -l
lsblkCorrect
mount

lsblk walks the kernel's own block-device tree and shows it as a hierarchy, which naturally includes things like LVM volumes, NVMe namespaces, and loop devices. Tools like df or mount only show what's currently mounted somewhere, not the full picture of every block device that exists.

medium

8. After deploying a new build, `systemctl status myapp` shows the service as 'failed'. What's the best next step to understand why it won't start?

Reinstall the operating system
Delete the service file and hope it regenerates
Reboot the entire server
Run journalctl -u myapp to view the service's logsCorrect

journalctl -u myapp shows the log output specifically captured from that systemd service, including the error that caused it to fail, which is the fastest way to diagnose the problem. Rebooting the server or reinstalling the OS doesn't address the underlying cause and wastes time, and deleting the service file would only make things worse.

hard

9. An engineer runs `ulimit -n 65535` in their SSH session to raise the file descriptor limit, but the systemd managed application service still crashes with 'too many open files' shortly after restart. What's the likely reason the change didn't help?

ulimit changes only take effect after a full server reboot
ulimit set in a shell session doesn't apply to services started by systemd; the limit needs to be set with LimitNOFILE in the unit fileCorrect
The application ignores file descriptor limits entirely
65535 is below the application's actual requirement, so a higher number is needed

A ulimit set interactively in a shell only affects processes started from that shell session, not services launched independently by systemd at boot or via systemctl. To raise the limit for a systemd managed service, you need to set LimitNOFILE= in that service's unit file (or a drop in override) and then reload systemd and restart the service. It's not about needing a reboot or a bigger number, the setting simply never reached the service in the first place.

easy

10. `ps aux` shows a process with state Z and the command listed as `<defunct>`. What does this mean?

The process is stuck waiting on disk I/O and cannot be interrupted.
The process's binary was deleted from disk while it was still running.
The process has finished executing but its parent hasn't yet read (reaped) its exit status, so its entry remains in the process table.Correct
The process has been paused by a SIGSTOP and is waiting to be resumed.

A zombie (Z state) process has already terminated; its exit code just hasn't been collected via wait() by the parent yet. It uses no CPU or memory, only a slot in the process table, and normally clears once the parent reaps it, or once the parent exits and the zombie is reparented and reaped by init. Uninterruptible I/O wait is D state, a different and often more urgent problem than a harmless zombie.

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.