Linux interview questions and answers for admins, DevOps and developers
Linux interview questions check whether you can operate a real server: find a process, read its logs, fix a permission, explain why a disk is full, and trace a network problem one layer at a time. Most rounds mix short command and concept questions with an open troubleshooting scenario such as "the box is slow" or "the service will not start", plus a small shell script. Interviewers score the order of your checks as much as the commands you know.
By Evin JohnPublished 10 min read
Who gets asked Linux questions, and how deep
Almost every infrastructure job tests Linux: system administrator, DevOps, site reliability, cloud and platform roles, and many backend developer loops. The depth changes with the title. A backend developer is expected to move around a shell, read logs, check ports and understand permissions. A sysadmin or SRE candidate is pushed further into the kernel's view of memory, the boot process, filesystems under pressure and live debugging with tools like strace. Fresher interviews stay on commands and concepts; experienced interviews are mostly scenarios.
- Rapid-fire basicsWhat a command does, what a permission string means, what a signal is. Short answers, often in a phone screen.
- Concept depthProcesses and memory, inodes and links, the boot sequence, how name resolution works on the host.
- Troubleshooting scenarioAn interviewer describes symptoms and answers your questions as you investigate. Sometimes a live VM or a terminal in a browser.
- Scripting taskWrite or fix a short bash script: parse a log, rotate files, check a service. Quoting and error handling get read closely.
Linux fundamentals questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is the difference between the kernel and user space? | Architecture | The kernel manages hardware, memory, scheduling and filesystems with full privileges. Programs run in user space and ask the kernel for work through system calls such as open, read and fork. |
| What does "everything is a file" mean? | Linux model | Devices, pipes, sockets and kernel data under /proc and /sys are reached through file descriptors and paths, so the same read and write tools work on them. |
| What is an inode? | Filesystems | The record that holds a file's metadata and block pointers: owner, mode, size, timestamps. The name lives in the directory entry, not in the inode. |
| Hard link versus symbolic link? | Links | A hard link is a second name for the same inode and cannot cross filesystems. A symlink stores a path, can cross filesystems and can dangle when its target is removed. |
Read -rwxr-x--- alice dev report.sh aloud. | Permissions | Owner alice can read, write and run it; group dev can read and run it; others get nothing. In octal that is 750. |
| What does umask do? | Defaults | It removes bits from the default mode of new files. With 027, new files come out 640 and new directories 750. |
| What are setuid, setgid and the sticky bit? | Special bits | Setuid runs a binary as its owner (passwd is the classic case). Setgid on a directory makes new files inherit its group. The sticky bit on /tmp lets only a file's owner delete it. |
| What do file descriptors 0, 1 and 2 stand for? | I/O | Standard input, output and error. Redirection works on these numbers, which is why 2>&1 sends errors wherever output already goes. |
What is the difference between sudo and su? | Privilege | su switches to another user with that user's password. sudo runs one command as another user under rules in sudoers, logs it and asks for your own password. Edit those rules with visudo. |
| Walk me through the boot process. | Boot | Firmware (UEFI or BIOS), the bootloader such as GRUB, the kernel with its initramfs, then the init system (systemd as PID 1) bringing up units until the default target is reached. |
Process and memory questions
- How is a new process created? A parent calls fork, which makes a copy that shares memory pages copy-on-write, and the child usually calls exec to replace itself with a new program. The shell does this for every external command you run.
- What is the difference between SIGTERM and SIGKILL? SIGTERM (15) asks the process to exit and can be caught, so it can flush and close cleanly. SIGKILL (9) cannot be caught or ignored. Send TERM first and wait before reaching for KILL.
- What does SIGHUP usually mean for a daemon? Many daemons treat it as "reload your configuration". Check the service's documentation, because the default action for a program that does not handle it is to exit.
- What is a zombie process and how do you clear it? A child that has exited but whose parent has not collected its exit status. You cannot kill a zombie; fix or restart the parent, and once the parent dies the orphan is adopted and reaped by PID 1.
- What does state D mean in `ps` output? Uninterruptible sleep, usually waiting on disk or network storage. Even SIGKILL waits until the I/O returns, so many D processes point at a storage problem, not at the processes themselves.
- What is load average? The average number of processes running, waiting for CPU, or (on Linux) in uninterruptible sleep, over 1, 5 and 15 minutes. Compare it with the number of CPUs, and remember a high load with idle CPU often means I/O wait.
- Why does `free` show almost no free memory on a healthy server? The kernel uses spare memory as page cache and gives it back on demand. The "available" column is the number that tells you how much new programs can use without swapping.
- What does the OOM killer do? When memory runs out, the kernel picks a process by its OOM score and kills it. The kernel log records it, so
journalctl -kordmesgshows which process died and why. - How do you find what a running process is doing?
toporhtopfor CPU and memory,lsof -p <pid>for its open files and sockets, andstrace -p <pid>to watch its system calls live.
Filesystems, disks and services
| Question | What it tests | What a strong answer shows |
|---|---|---|
df says the disk is full but du adds up to far less. Why? | Open deleted files | A process still holds a deleted file open, so its blocks are not freed. lsof +L1 lists such files; restart or signal the process to release it. |
Writes fail with "No space left on device" yet df -h shows free space. | Inodes | The filesystem ran out of inodes, usually from millions of tiny files. df -i confirms it; find the directory with the most files and clean it. |
| How do you mount a disk so it survives a reboot? | Mounts | Create the filesystem, add a line to /etc/fstab using the UUID from blkid, then run mount -a to test it before rebooting. A bad fstab line can stop a clean boot. |
| Why use LVM? | Storage | Logical volumes can be grown, moved and snapshotted without repartitioning, which makes resizing a full volume a short job instead of an outage. |
| How do you see why a systemd service failed? | systemd | systemctl status name for the last lines and exit code, then journalctl -u name -b for the full log of this boot. |
| You edited a unit file and nothing changed. Why? | systemd | systemd caches unit definitions. Run systemctl daemon-reload, then restart the service. |
| Enable versus start? | systemd | start runs it now; enable makes it start at boot. enable --now does both. |
| How would you schedule a nightly job? | Scheduling | A cron entry (minute, hour, day of month, month, day of week) or a systemd timer. Cron runs with a minimal PATH and environment, which is the usual reason a script works by hand and fails at night. |
Linux networking questions
- Which process is listening on port 443?
ss -tulpnlists listening TCP and UDP sockets with their processes (run it with sudo to see other users' processes).lsof -i :443works too. - How does the host resolve a name?
/etc/nsswitch.confsets the order, usually/etc/hostsfirst and then DNS servers from/etc/resolv.conf. On systemd-resolved systems that file often points at a local stub resolver. - A service on another machine is unreachable. Where do you start? Name resolution with
dig, routing withip routeandtraceroute, the port withnc -zv host portorcurl -v, then firewalls on both ends. Work from the bottom layer up and say each result out loud. - Why does an app answer locally but not from outside? It is bound to 127.0.0.1 instead of 0.0.0.0, or a host firewall (nftables, iptables, firewalld or ufw) drops the port, or a cloud security rule does.
- What is a connection in TIME_WAIT? The side that closed first keeps the socket briefly so late packets are not confused with a new connection. Thousands of them usually point at clients opening a fresh connection per request instead of reusing one.
- How do you capture traffic to prove a request reaches the box?
tcpdump -i any port 8080 -nnon the server. If packets arrive and nothing answers, the problem is on the host; if nothing arrives, look upstream. - How do you harden SSH? Keys instead of passwords,
PasswordAuthentication noand no direct root login insshd_config, the.sshdirectory at 700 andauthorized_keysat 600, and access limited by firewall or a bastion host.
uptime # load averages versus the CPU count from nproc
top -o %CPU # who is using CPU; watch the wa (I/O wait) figure
free -h # look at "available", not "free"
vmstat 1 5 # run queue, swapping (si/so) and I/O wait over time
iostat -xz 1 3 # per-disk utilization and latency (sysstat package)
df -h && df -i # space and inodes
journalctl -k --since "1 hour ago" # kernel messages: OOM kills, disk errors
ss -s # socket summary: a flood of connections?Troubleshooting scenarios for experienced candidates
| Scenario | First checks | What a strong answer adds |
|---|---|---|
| A web service will not start after a deploy. | systemctl status, then the journal for the unit, then the config test command the service offers (for example nginx -t). | Checks whether the port is already taken, whether the user can read its files, and whether SELinux or AppArmor denied access. |
| You cannot SSH into a server that is otherwise up. | Is port 22 reachable, is sshd running, what does the client say with ssh -v? | Mentions the cloud console or serial console as the way in, and checks for a full disk or wrong permissions on authorized_keys. |
| A job got slower every day this month. | Data growth, disk latency, swap use, log volume. | Compares against a baseline and looks for a resource trending toward a limit instead of guessing. |
| Memory use climbs until the process is killed. | OOM lines in the kernel log, the process's resident size over time. | Separates a real leak from cache growth and proposes a limit plus an alert while the leak is fixed. |
Permission denied even though the mode bits look right. | Every directory on the path needs execute permission; check ACLs with getfacl. | Brings up SELinux contexts (ls -Z) or a filesystem mounted read-only or with noexec. |
| The clock on a server is drifting. | timedatectl and the NTP client status (chrony or systemd-timesyncd). | Explains why drift breaks TLS, Kerberos and log correlation across machines. |
Fictional example
- Interviewer
- You get paged: /var on a production host is at 97 percent. Talk me through it.
- Candidate
- First I confirm the alert with
df -h /varanddf -i /var, because space and inodes are different problems. Then I find where the space is withdu -xh -d 1 /var | sort -h, walking down into the biggest directory. On most hosts it ends up being logs or a stuck queue. Ifduanddfdisagree, I checklsof +L1for a deleted log that a process still has open; truncating it or restarting that process frees the space. For a quick fix I compress or remove old rotated logs, never the live file a service is writing. Afterwards I want to know why rotation did not keep up: a missing logrotate rule, a debug level left on, or a crash loop writing stack traces. I would add an alert at a lower threshold with a growth rate, so we hear about it days earlier next time.
Shell scripting questions
- Why quote variables? An unquoted variable is split on spaces and expanded as a glob, so a file name with a space becomes two arguments. Write
"$file"unless you have a reason not to. - What does `set -euo pipefail` do, and what are its limits? Exit on an error, treat unset variables as errors, and fail a pipeline when any stage fails. It does not fire inside
ifconditions or on the left of&&, so it is a safety net, not error handling. - What is the difference between `>file 2>&1` and `2>&1 >file`? Redirections apply left to right. The first sends both streams to the file; the second points stderr at the old stdout (the terminal) before stdout moves.
- How do you clean up a temporary file even when the script fails? Create it with
mktempand registertrap 'rm -f "$tmp"' EXITstraight after. - How do you run a command on many files safely?
find ... -print0 | xargs -0 cmdorfind ... -exec cmd {} +, which survive spaces and newlines in names. Never loop overlsoutput. - How do you check whether the last command succeeded? Its exit status is in
$?, but it is cleaner to test the command directly:if grep -q pattern file; then ....
#!/usr/bin/env bash
set -euo pipefail
log_file="${1:?usage: top-clients.sh LOGFILE [COUNT]}"
count="${2:-10}"
if [[ ! -r "$log_file" ]]; then
echo "cannot read $log_file" >&2
exit 1
fi
# In the common log format the first field is the client address.
cut -d ' ' -f 1 "$log_file" | sort | uniq -c | sort -rn | head -n "$count"#!/usr/bin/env bash
set -euo pipefail
mount_point="${1:-/}"
limit="${2:-90}"
read -r _ _ _ _ used_pct _ < <(df -P "$mount_point" | tail -n 1)
used="${used_pct%\%}"
if (( used >= limit )); then
echo "WARN: $mount_point is at ${used}% (limit ${limit}%)" >&2
exit 2
fi
echo "OK: $mount_point is at ${used}%"A one-week Linux practice plan
- Day 1: on a throwaway VM, create users and groups, set modes with chmod in octal and symbolic form, and test umask, setgid directories and the sticky bit until you can predict every result.
- Day 2: start a process, inspect it with ps, top, lsof and strace, then send it TERM and KILL and watch the difference. Create a zombie on purpose with a small script and clear it.
- Day 3: write a small systemd service, break it in three ways (bad path, wrong user, port in use) and fix each from the journal alone.
- Day 4: fill a disk with a large file and then with many small files; delete an open log and find it with lsof. Add a disk to fstab by UUID.
- Day 5: networking. Bind a server to localhost and then to all addresses, block a port with the firewall, and trace each failure with ss, curl and tcpdump.
- Days 6 and 7: write the two scripts above from memory, run them through shellcheck, and talk through the "slow server" checklist out loud with a timer.
Linux rarely comes alone. DevOps engineer interview questions adds CI/CD and incident rounds, backend developer interview questions covers the application side, and Git interview questions is the other command-line topic most engineering loops check. For scale questions that build on these basics, see system design guides.
A troubleshooting round is a spoken investigation, and it is hard to judge your own order of checks from memory. Natively, an AI interview assistant that runs on your Mac or Windows laptop, can transcribe a mock round with a friend playing the paged on-call lead, so you can read back where you jumped to a fix before collecting evidence. While practicing it can also read a screenshot of a terminal error or a script and suggest what to check next. With Pro or the free trial it can use the résumé and job description you add, and the transcript and notes are saved on your computer for review.
Questions people ask
What Linux questions are asked in interviews?
File permissions and umask, inodes and links, processes and signals, load average and memory, systemd and logs, disk and inode problems, network checks with ss, dig and curl, and a short bash script.
How do I answer a Linux troubleshooting question?
Work from evidence: confirm the symptom, check the cheapest signals first (load, memory, disk, logs), narrow to one process or layer, then fix and say how you would stop it happening again.
What Linux commands should I know for an interview?
At least ps, top, kill, df, du, free, lsof, ss, ip, dig, curl, journalctl, systemctl, find, grep, chmod and chown, and you should be able to read their output out loud.
Are Linux interview questions different for freshers and experienced candidates?
Yes. Freshers mostly get command and concept questions. Experienced candidates get open scenarios such as a full disk or a failing service and are judged on the order of their checks.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
