INTERVIEW PREP
Interview questions
570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.
Showing 1–15 of 229 questions
1.What is the difference between a process and a thread?BeginnerLinux
A process has its own memory space, file descriptors and PID. Threads live inside a process and share its memory, so they are cheaper to create and switch between but can corrupt each other's data. On Linux both are 'tasks' created with clone(); threads simply share more.
2.How do you find which process is listening on port 8080?BeginnerLinux
ss -ltnp | grep :8080 (or sudo lsof -i :8080). The -l shows listening sockets, -t TCP, -n numeric ports, -p the owning process. Mention you need root to see other users' processes.
3.What do the permissions rwxr-x--- mean, and how do you set them?BeginnerLinux
Owner can read, write and execute; group can read and execute; others have nothing. In octal that is 750: chmod 750 file. For directories, x means 'may enter the directory'.
4.What is the difference between a hard link and a soft (symbolic) link?BeginnerLinux
A hard link is a second name for the same inode, so the data stays until every name is deleted; it can't cross filesystems or point to folders. A soft link is a small file that stores a path; it can point anywhere, but breaks if the target is moved or deleted. Create them with ln file link and ln -s target link.
5.How do you check disk space and find what is using it?BeginnerLinux
df -h shows free space per filesystem. du -sh /var/* | sort -h shows which folders are biggest. ncdu is a friendly interactive version if it is installed.
6.What is the difference between > and >>, and what does 2>&1 mean?BeginnerLinux
> writes output to a file and replaces it; >> appends. 2>&1 sends standard error (file descriptor 2) to wherever standard output (1) is going, so cmd > log 2>&1 captures both.
7.How do you see the last lines of a log and follow new ones?BeginnerLinux
tail -n 100 /var/log/app.log shows the last 100 lines and tail -f keeps printing new lines. For systemd services, journalctl -u app -f does the same from the journal.
8.A disk is 100% full but du shows much less used. Why?MidLinux
A process still holds a deleted file open, so its blocks are not freed. Find it with lsof +L1 (or lsof | grep deleted), then restart that process or truncate the file through /proc/PID/fd. Also check inode exhaustion with df -i.
9.What happens when you run kill PID, and when would you use kill -9?MidLinux
kill sends SIGTERM, which a program can catch to shut down cleanly (flush data, close connections). SIGKILL (-9) cannot be caught; the kernel ends the process immediately, risking corrupt data. Use -9 only after SIGTERM has had time to work.
10.How does a systemd service restart automatically, and how do you see why it failed?MidLinux
Set Restart=on-failure (with RestartSec=) in the unit. Use systemctl status app for the latest state and exit code, and journalctl -u app -n 100 --no-pager (or -f to follow) for logs.
11.How do you find which files were changed in the last 24 hours?MidLinux
find / -xdev -type f -mtime -1 lists files modified less than one day ago on the root filesystem. Use -mmin -60 for the last hour, and -newer file to compare with a reference file.
12.What is an inode, and how can you run out of them?MidLinux
An inode stores a file's metadata (owner, permissions, where the data is) but not its name. Each filesystem has a fixed number. Millions of tiny files (cache, sessions, mail queue) can use them all while space is free; df -i shows it and No space left on device is the symptom.
13.How do you check which ports are open and what is listening on them?MidLinux
ss -tulpn lists TCP and UDP listening sockets with the owning process. From another host, nc -zv host 443 or nmap tests if the port is reachable, which also shows firewall problems.
14.What is the difference between sudo su, sudo -i and sudo command?MidLinux
sudo command runs one command as root and is logged, which is best practice. sudo -i starts a root login shell with root's environment. sudo su switches to root through su; it works but hides what you did afterwards from the sudo log.
15.How do you schedule a job, and why might a cron job work by hand but fail in cron?MidLinux
Use crontab -e or a systemd timer. Cron runs with a tiny environment: a short PATH, no shell profile, a different working directory and no terminal. Use full paths, set variables in the script, and send output to a log to see the error.