Linux shows up in almost every DevOps interview, and for good reason. The servers you deploy to run Linux, the containers you build run on Linux, and the CI runners and cloud instances underneath it all run Linux. An interviewer asking about Linux is not testing whether you memorized a cheat sheet — they are testing whether you can read a system that is misbehaving and reason your way to the fix.
This guide collects 50 Linux interview questions and answers for DevOps engineers, organized by theme: fundamentals, files and permissions, processes, systemd, networking, disk and logs, and the troubleshooting scenarios interviewers love most. If you are still building your foundation, start with our Linux for DevOps engineers guide first.
Linux Fundamentals
1. What is the difference between Linux and a distribution?
Linux is a kernel, not a complete operating system: it schedules processes, manages memory, handles devices and enforces security. A distribution such as Ubuntu or Red Hat Enterprise Linux adds the userland — shell, package manager, init system and utilities — to that kernel to make a usable system; the official Linux kernel documentation is the authoritative reference.
2. What is the difference between Linux and Unix?
Unix is the family of operating systems that began at Bell Labs in the 1970s. Linux is a Unix-like kernel written from scratch in the early 1990s, following the same philosophy — small tools, text streams, everything is a file. Commands transfer between them, so Linux skills work on macOS and BSD too.
3. What is a shell, and how does bash differ from sh?
A shell is the command interpreter: the program that reads what you type, runs it, and shows you the result. bash is the default interactive shell on most Linux distributions, adding tab completion, history, arrays and job control, while sh is the POSIX shell — often a minimal shell. Use #!/bin/bash for bash features and #!/bin/sh for portability.
4. What is the difference between a process and a thread?
A process is a running program with its own memory space, file descriptors and process ID. A thread is a unit of execution inside a process: threads share memory and file descriptors, so communication is fast — but one thread can also corrupt another’s data.
5. What is the difference between user space and kernel space?
Kernel space is where the kernel runs, with full access to hardware and memory. User space is where applications run with restricted access, and a program there cannot touch hardware directly — it must ask the kernel through a system call. That split is why a crashing application rarely crashes the machine, and why a process stuck in state D cannot be killed.
6. How do you choose a Linux distribution for production?
There is no single best choice; the right answer depends on the environment. Ubuntu LTS is the most common choice in cloud and CI, while Red Hat Enterprise Linux and its rebuilds dominate regulated enterprises where vendor certification matters.
7. What does LTS mean, and why does it matter?
LTS stands for Long Term Support: a release that receives security and maintenance updates for years rather than months — Ubuntu 24.04 LTS, for example, is supported until 2029. Servers should run LTS releases because nobody wants to rebuild production machines every nine months, and security patches keep arriving without a disruptive upgrade.
8. How do you check the distribution and kernel version?
cat /etc/os-release
uname -a
hostnamectl
/etc/os-release gives the distribution name and version in a format scripts can parse. uname -a gives the kernel version, architecture and hostname in one line — the kernel version is what matters when a feature or a bug depends on it. hostnamectl shows both, plus the machine ID and virtualization details.
Files, Directories and Permissions
9. What lives in /etc, /var, /opt and /usr?
The Filesystem Hierarchy Standard gives every directory a job: /etc holds system configuration files such as /etc/nginx/nginx.conf, and /var holds data that changes while the system runs, including logs in /var/log and application data in /var/lib. /opt holds optional, self-contained software installed outside the package manager, while /usr holds user programs and libraries installed by packages.
10. What does each column of ls -l output mean?
-rw-r--r-- 1 deploy deploy 2048 Dec 4 09:30 app.conf
Reading left to right: the first character is the file type (- regular file, d directory, l symlink), the next nine characters are the permissions for owner, group and others, then the link count, the owner, the group, the size in bytes, the modification time, and the name.
11. What do chmod 755, 644 and 600 mean?
Each permission is a number: read is 4, write is 2, execute is 1 — add them for owner, group and others. 755 gives the owner read, write and execute (4+2+1) and everyone else read and execute; 644 gives the owner read and write and everyone else read only; 600 gives only the owner read and write, the standard for private keys.
12. What is umask, and why does it matter?
The umask is the permission mask applied when a new file or directory is created: files get mode 666 minus the umask, directories 777 minus the umask, so the default 022 gives new files 644 and new directories 755. A restrictive umask such as 077 makes new files 600, so a web server running as another user cannot read them.
13. What are the setuid, setgid and sticky bits?
These are three special permission bits beyond read, write and execute. Setuid (4000) makes a program run with its owner’s permissions — /usr/bin/passwd needs root privileges to edit /etc/shadow. Setgid (2000) on a directory makes new files inherit its group, and the sticky bit (1000) on /tmp means only the file’s owner can delete it.
14. What is the difference between hard and symbolic links?
A hard link is a second name for the same inode, so deleting one name leaves the data intact under the other. Hard links cannot point to directories or cross filesystems. A symbolic link is a separate file containing a path to another file, so it can break if the target moves.
15. Why does a directory need execute permission?
On a directory, read lists the contents, write creates, deletes and renames entries, and execute lets you traverse into it. That last point is the one interviewers probe — a directory with read but no execute lets you see filenames but not open any of them, while one with execute but no read lets you open a file if you know its exact name.
16. When do you use find versus locate?
find /var/log -name "*.log" -mtime -1
find /opt -type f -size +100M
Use find for a live, accurate search with conditions. Use locate for speed when a slightly stale answer is fine: it searches a database built by updatedb, usually once a day.
Processes and Signals
17. How do you find CPU and memory hogs?
Start with ps aux for a snapshot of every process, or ps aux --sort=-%mem | head to rank by memory. For a live view, use top, or htop if it is installed — its tree view (F5) shows parent and child processes together.
18. What is load average, and how do you interpret it?
Load average, shown by uptime or top, is the average number of processes waiting to run or on I/O. A load of 1.00 on a single-CPU machine means the CPU is fully busy; on a four-CPU machine, 4.00 is full utilization. The common mistake is treating high load as proof of a CPU problem: load also counts processes waiting on disk I/O.
19. What is the difference between SIGTERM and SIGKILL?
kill sends SIGTERM (signal 15), a polite request to shut down. The process can catch it, finish its current work, flush buffers, close files and exit cleanly. kill -9 sends SIGKILL (signal 9), which the process cannot catch or ignore — the kernel terminates it immediately, with no cleanup — so always try SIGTERM first.
20. What are zombie and orphan processes?
A zombie is a finished process whose parent has not read its exit status, so its table entry remains. You cannot kill it — it is already dead — so make the parent reap it, or restart the parent. An orphan is the opposite: its parent died first, and PID 1 adopts it.
21. How do you keep a process running after you log out?
Append & to run a command in the background; use jobs, fg and bg to manage it. But a background job still dies when the shell exits, because it receives SIGHUP on logout — to survive logout, use nohup, which makes the process ignore SIGHUP: nohup python app.py > app.log 2>&1 &.
22. What are nice values, and how do you change them?
Every process has a nice value from -20 (highest priority) to 19 (lowest), with 0 as the default, and the scheduler gives more CPU time to lower nice values. Set a priority with nice -n 10 ./backup.sh at start, or renice -n 5 -p 1234 later; raising priority needs root.
23. What are namespaces and cgroups?
Namespaces and cgroups are the two kernel features containers are built on. Namespaces isolate what a process can see: its own process IDs, network interfaces, mount points and hostnames, so a process inside a container believes it is alone on the machine. Cgroups limit what a process can use — CPU, memory and disk I/O — which is how Docker enforces --memory and --cpus limits.
24. What is the OOM killer?
dmesg | grep -i "out of memory"
journalctl -k | grep -i "killed process"
When the system runs out of memory, the kernel’s out-of-memory (OOM) killer terminates a process to protect the rest of the system, usually the largest memory consumer. The evidence is in the kernel log, shown above. Check free -h and ps aux --sort=-%mem for the biggest consumers.
systemd and Services
25. What is systemd, and what does it do as PID 1?
systemd is the init system and service manager on almost every mainstream Linux distribution. As PID 1, it is the first process the kernel starts and the parent of every other process: it starts services at boot, restarts them when they fail, and collects their logs.
26. What do systemctl start, enable, restart and reload do?
start runs a service now; enable makes it start at boot — the two are independent, and confusing them is the classic beginner mistake. systemctl enable --now nginx does both at once. restart stops and starts the process, dropping in-flight connections, while reload asks the running process to re-read its configuration without stopping.
27. What are the sections of a systemd unit file?
A unit file is a small declarative text file that describes a thing systemd manages. A service unit has three sections: [Unit] for the service and its dependencies; [Service] for how to run it; [Install] for when it should start. Custom units live in /etc/systemd/system/; packaged units live in /usr/lib/systemd/system/ and must never be edited directly — after any change, run systemctl daemon-reload.
28. What do the Type= settings in a service unit mean?
Type= tells systemd how to know the service has started. simple is the default: systemd considers the service started as soon as the ExecStart process is running. exec waits until the binary has actually been executed; forking is for old daemons, oneshot for tasks that run and exit, and notify for services that tell systemd they are ready. The official systemd.service manual page recommends exec for long-running services.
29. How do Restart= and the start limit settings work?
Restart=on-failure restarts the process when it exits with a non-zero status or is killed by a signal, but not when it exits cleanly with status zero — that would loop forever. RestartSec=5 waits five seconds between restarts. StartLimitIntervalSec=60 with StartLimitBurst=3 stops trying after three failures in sixty seconds.
30. A service fails to start. How do you debug it?
systemctl status myapp --no-pager
journalctl -u myapp --since "15 minutes ago" --no-pager
Start with the status output: status 203 means the executable could not be found or run, usually a wrong path in ExecStart, while a timeout points at a slow start or a wrong Type=. Then check the usual causes: a missing WorkingDirectory, missing environment variables, wrong ownership, a port already in use, and a forgotten daemon-reload.
31. How do you read service logs with journalctl?
journalctl -u nginx -f
journalctl -u nginx --since "1 hour ago"
journalctl -p err --since today
systemd collects the output of the services it manages in the journal, and journalctl reads it. -f follows the log live, like tail -f; --since limits the output to recent entries; -p err shows only errors and worse.
32. What is the difference between a systemd timer and cron?
Both schedule recurring jobs, but a timer is a unit, so it has logging, status and failure handling built in — check its history with journalctl -u backup.service and its next run with systemctl list-timers --all. A timer with Persistent=true runs a job missed while the machine was off.
Networking
33. How do you check what is listening on a port?
ss -tulpn
ss -tlnp | grep :8080
Use ss, the modern replacement for netstat. The flags are worth memorizing: -t TCP, -u UDP, -l listening only, -p process, -n no DNS lookups. If ss does not show your application on port 8080, it is not running or not bound to that port — check systemctl status and the application log first.
34. Why does a service work on localhost but not remotely?
Work through the layers in order. First, confirm the service is listening on the right address: 127.0.0.1:8080 means local connections only, while 0.0.0.0:8080 means all interfaces. Second, test with curl localhost:8080/health — if that works, the application is fine. Third, check the firewall, then the cloud security group — the most commonly forgotten layer.
35. What is the difference between TCP and UDP?
TCP is connection-oriented and reliable: it guarantees delivery and order and retransmits lost packets. UDP is connectionless and best-effort: packets may arrive out of order or not at all. Almost everything in DevOps runs on TCP; UDP shows up for DNS, syslog and SNMP.
36. How does DNS resolution work on a Linux machine?
When an application asks for a name, the resolver works through a defined order: first it checks /etc/hosts for a local override, then it queries the DNS servers listed in /etc/resolv.conf. Two commands show different views: getent hosts example.com uses the system’s normal resolution, including /etc/hosts; dig example.com talks directly to DNS.
37. What is the difference between curl and wget?
curl -I https://example.com
curl -v https://api.example.com/health
curl --max-time 5 https://example.com
Both download files over HTTP, but they are built for different jobs. curl is a diagnostic tool: it prints the response to standard output, supports custom methods and headers, and shows verbose detail with -v — the right choice for testing APIs. wget is a download tool: it saves files to disk, follows redirects and retries by default.
38. How do you test connectivity step by step?
Separate the layers, because each has its own fix. ping -c 4 8.8.8.8 tests IP connectivity without DNS; ping -c 4 example.com adds DNS — if the first works and the second fails, DNS is the problem. ip route show checks for a default gateway, and traceroute example.com shows where the route breaks. Finally, test the specific port with curl -v or nc -zv host 443.
39. What is the difference between ufw and firewalld?
Both are front ends to the kernel’s packet filtering. Ubuntu and Debian use ufw: sudo ufw allow 22/tcp and sudo ufw enable are the whole workflow. Red Hat Enterprise Linux, Fedora and Rocky Linux use firewalld, which separates runtime from permanent configuration: a rule added without --permanent disappears at the next reload.
40. How does SSH key authentication work?
SSH key authentication replaces passwords with a key pair: a private key that stays on your machine, and a public key that goes on the server. Generate the pair with ssh-keygen -t ed25519, copy the public key with ssh-copy-id user@server, and the server verifies you by challenging you to prove you hold the private key. The permissions are enforced: ~/.ssh must be 700 and authorized_keys must be 600, or SSH ignores the key.
Disk, Memory and Logs
41. What is the difference between df and du?
df -h shows free space per filesystem — how much room is left on each mounted disk. du -sh /var/log/* shows how much space directories and files use. Use df to find which filesystem is full, then du to find what is filling it. They can disagree: a file deleted while a process still holds it open keeps consuming space in df — find those with lsof | grep deleted.
42. Why do writes fail when df shows free space?
Two causes cover most cases. The first is inode exhaustion: every file uses an inode, and a filesystem can run out of inodes while still having free bytes — check with df -i. The second is a filesystem mounted read-only, often because the kernel remounted it after an I/O error.
43. How do you read memory usage with free -h?
free -h shows total, used, free, shared, buff/cache and available memory. The number that matters is available, not free: Linux uses spare RAM as disk cache, so a healthy machine often shows very little free memory while having plenty available.
44. Where do Linux logs live, and how do you search them?
grep -rn "connection refused" /var/log/ | tail -n 50
grep -i "error" /var/log/nginx/error.log | tail -n 100
Traditional logs live in /var/log: syslog or messages for system events, auth.log or secure for authentication. Services managed by systemd also log to the journal, read with journalctl. Search with grep — -r recursive, -n line numbers, -i case-insensitive — and pipe into tail to see the most recent matches first.
45. What is log rotation, and why does it matter?
Log rotation, handled by logrotate, periodically compresses, renames and deletes old log files so they do not fill the disk. The configuration lives in /etc/logrotate.conf and /etc/logrotate.d/, and you can test a configuration without waiting with logrotate -d /etc/logrotate.d/nginx.
Troubleshooting Scenarios
46. Scenario: 502 Bad Gateway after a deploy. How do you debug it?
A 502 means the reverse proxy is running but the application behind it is not answering, so start at the application. First, systemctl status myapp — is the service running? Second, journalctl -u myapp --since "15 minutes ago" for the startup error. Third, ss -tlnp | grep 8080 to confirm it is listening, then curl localhost:8080/health — if that works, check the nginx error log.
47. Scenario: load average 25 on a 4-CPU machine. What do you do?
First, identify the kind of load. Run top: high %us means user processes are burning CPU, while high %wa (iowait) means processes are waiting on disk. If it is CPU, ps aux --sort=-%cpu | head finds the culprit. If it is iowait, iotop or iostat -x 1 finds the disk hog. Do not reboot first: a reboot destroys the evidence and the problem returns.
48. Scenario: You cannot SSH into a server. What do you check?
Work from the client outward: try another host first. ping tests IP connectivity, and nc -zv server 22 tests whether port 22 is open. If the port is closed, the SSH daemon may be down, or the firewall or security group may be blocking it. If authentication fails, check permissions — ~/.ssh must be 700 and authorized_keys 600 — or a replaced key.
49. Scenario: a cron job runs locally but not on the server. Why?
Start with the environment, because it is the cause nine times out of ten. Cron runs with a minimal environment: a short PATH, no loaded shell profile, and none of your .bashrc variables. A script calling python or docker by bare name works in your shell and fails in cron, because the binary is not in cron’s PATH. The fixes are to use absolute paths, set PATH explicitly in the crontab, and source the environment the script needs.
50. Scenario: the disk is 100% full. How do you recover safely?
Move fast but do not delete blindly. First, df -h to find which filesystem is full, then du -h --max-depth=1 /var | sort -h to find the growth. Check for deleted files held open by processes with lsof | grep deleted — deleting them frees nothing until the process restarts. Safe space to reclaim: old logs, old Docker images and stopped containers, package caches, and files in /tmp.
Frequently Asked Questions
How many Linux interview questions should I prepare for a DevOps role?
Prepare the fifty in this guide and you will cover the vast majority of what interviewers ask. They ask the same core topics — permissions, processes, systemd, networking and troubleshooting — in different scenarios. Depth beats breadth: walking through a failed service start beats reciting unused commands.
Which Linux distribution should I learn first?
Ubuntu is the best starting point: it is the most common distribution in cloud, containers and tutorials, its documentation is excellent, and the commands you learn transfer to other distributions. Once you are comfortable, learn Red Hat family systems too.
Do I need to learn shell scripting for a DevOps interview?
Yes, at a working level. You do not need to write complex programs, but you should be able to write a script that loops over files, checks a service, and parses a log. Interviewers often ask you to write a small script on the spot, such as checking disk usage.
How should I prepare for a Linux interview in one week?
Set up a disposable virtual machine or a cheap cloud instance and break things deliberately: fill the disk, stop a service, misconfigure a firewall, kill a process. Then fix each one using only the terminal.
Are Linux questions still asked for senior DevOps roles?
Yes, and the questions get harder, not easier. Senior interviews focus less on naming commands and more on design and failure: hardening a service unit, choosing a systemd timer over cron, and designing a resilient fleet.
Conclusion
Linux interview questions are not a memory test. They are a check on whether you can think like an operator: observe the system, form a hypothesis, test it with the cheapest command available, and fix the cause rather than the symptom. The fifty questions here cover the ground interviewers return to again and again — permissions, processes, systemd, networking, disk and logs, and troubleshooting sequences.
The fastest way to make this knowledge stick is to use it. Build a small server, deploy an application with a systemd unit, break it, and fix it with the commands you have just read. Then keep going: work through our systemd tutorial and Linux commands guide until the troubleshooting sequence is automatic.



