Linux Interview Questions and Answers

34 questions with short, clear answers · Updated December 2026

Linux is the base of almost every cloud and DevOps job, so interviewers test it early. These questions cover what a Linux system administrator or DevOps engineer is expected to know: the file system, permissions, processes and systemd, networking, disks and shell scripting, with troubleshooting scenarios at the end.

Try each command on a practice machine as you read: being able to type the command quickly matters as much as knowing what it does.

Linux basics and the file system

Q1. What is the difference between the Linux kernel and a distribution?

The kernel is the core that manages hardware, memory, processes and system calls. A distribution (Ubuntu, Red Hat Enterprise Linux, Rocky Linux, Debian, Amazon Linux) packages the kernel with system tools, a package manager (apt or dnf), an init system (systemd) and default configuration. In interviews, know one Debian-based and one Red Hat-based distribution.

Q2. Explain the main directories in the Linux file system.

/etc holds configuration, /var variable data such as logs (/var/log) and spools, /home user directories, /root the root user's home, /usr installed programs and libraries, /bin and /sbin essential commands (now usually links into /usr), /tmp temporary files, /boot the kernel and bootloader files, /dev device files, /proc and /sys virtual files exposing kernel and process information, and /opt optional third-party software.

Q3. What is an inode?

An inode stores a file's metadata: owner, permissions, size, timestamps and the location of its data blocks, but not its name. Directory entries map names to inode numbers. A file system can run out of inodes before it runs out of space when there are millions of tiny files; df -i shows inode usage.

Q4. What is the difference between a hard link and a soft link?

A hard link is another name for the same inode: it shares the data, cannot cross file systems or point to directories, and the data survives until the last link is deleted. A soft (symbolic) link is a small file containing a path to the target: it can cross file systems and point to directories, but breaks if the target is moved or deleted. Create them with ln and ln -s.

Q5. How do you find files and search text in files?

find searches by name, size, time, owner or type, for example find /var/log -name "*.log" -mtime +7 for logs older than seven days, and can act on results with -exec or -delete. grep searches inside files, for example grep -rin "error" /var/log/nginx; -r recursive, -i ignore case, -n line numbers, -v invert, -E extended regex.

Q6. What do awk, sed, cut, sort and uniq do?

awk processes text by fields, for example awk '{print $1}' access.log prints the first column. sed edits streams, for example sed -i 's/old/new/g' file. cut extracts columns by delimiter, sort orders lines, and uniq removes or counts adjacent duplicates. A classic combination: awk '{print $1}' access.log | sort | uniq -c | sort -rn | head shows the top client IPs.

Users, permissions and sudo

Q7. Explain Linux file permissions and chmod 755.

Each file has read (4), write (2) and execute (1) permissions for the owner, the group and others. 755 means the owner has rwx (7) and group and others have r-x (5), typical for scripts and directories. 644 (rw-r--r--) is typical for normal files. For a directory, x means you can enter it and r means you can list it.

Q8. What are SUID, SGID and the sticky bit?

SUID on an executable makes it run with the file owner's privileges, as /usr/bin/passwd does to update /etc/shadow. SGID on a directory makes new files inherit the directory's group, useful for shared team folders. The sticky bit on a directory (as on /tmp) lets users delete only their own files. Unexpected SUID files are a security risk; find / -perm -4000 lists them.

Q9. What is umask?

umask removes permissions from the defaults given to new files (666) and directories (777). With the common umask 022, new files get 644 and new directories 755; with 027, others get no access. It is set per shell or user, for example in the shell profile or the systemd service file.

Q10. Where are users and passwords stored?

/etc/passwd lists accounts (name, UID, GID, home directory, shell) and is readable by all. Password hashes are in /etc/shadow, readable only by root, along with password ageing settings. Groups are in /etc/group. Manage them with useradd, usermod (for example usermod -aG docker user), passwd and chage.

Q11. How do you give a user limited admin rights?

Add a rule with visudo (which checks syntax) or a file in /etc/sudoers.d, for example allowing a deploy user to run only systemctl restart nginx without a password. Prefer giving specific commands rather than full sudo, and keep root SSH login disabled so admins log in as themselves and actions are logged.

Q12. What are SELinux and AppArmor?

They are mandatory access control systems that limit what a process can do even if it runs as root. SELinux (default on Red Hat-based systems) labels files and processes and enforces policies; getenforce shows the mode and audit logs show denials. AppArmor (default on Ubuntu) uses per-program path-based profiles. Fix denials by correcting labels or policies, not by disabling the system.

Processes, services and boot

Q13. What is the difference between a process and a thread, and what is a zombie process?

A process has its own memory space; threads are units of execution inside a process that share its memory. A zombie is a process that has finished but whose parent has not yet read its exit status; it uses no CPU or memory, only a process table entry. Many zombies point to a buggy parent; they disappear when the parent collects them or exits.

Q14. What is the difference between kill, kill -9 and kill -15?

kill sends SIGTERM (15) by default, asking the process to shut down cleanly: close files, finish requests, clean up. kill -9 sends SIGKILL, which the process cannot catch, so it stops immediately without cleanup and may leave corrupt files or locks. Always try SIGTERM first and use SIGKILL only if the process does not exit.

Q15. How do you manage services with systemd?

systemctl start, stop, restart, reload and status manage a service; systemctl enable makes it start at boot. Unit files live in /etc/systemd/system (yours) and /usr/lib/systemd/system (from packages); run systemctl daemon-reload after editing one. Logs are read with journalctl -u <service>, adding -f to follow or --since "1 hour ago".

Q16. What does load average mean?

The three numbers in uptime or top are the average number of processes running or waiting (for CPU, and on Linux also for disk I/O) over 1, 5 and 15 minutes. Compare them with the number of CPU cores (nproc): a load of 4 on a 4-core machine is fully used; a much higher load means work is queuing. High load with low CPU use usually points to slow disk or network storage.

Q17. Describe the Linux boot process.

Firmware (UEFI or BIOS) runs and finds the bootloader (GRUB), which loads the kernel and an initramfs. The kernel initialises hardware, mounts the root file system using the initramfs, and starts PID 1, systemd, which starts services in parallel to reach the default target (for example multi-user.target or graphical.target).

Q18. How do you schedule a job in Linux?

With cron: crontab -e adds lines such as 30 1 * * * /opt/backup.sh (01:30 every day); the five fields are minute, hour, day of month, month and day of week. Use full paths and redirect output to a log, because cron runs with a minimal environment. systemd timers are the modern alternative, with logging through journald and handling of missed runs.

Networking

Q19. Which commands do you use to check network configuration and open ports?

ip addr and ip route show addresses and routes (ifconfig and route are older); ss -tulpn lists listening TCP and UDP ports with their processes (netstat is older); ping tests reachability; traceroute or mtr shows the path; dig or nslookup tests DNS; curl -v tests HTTP; and nc -zv host port checks if a port is open.

Q20. How does DNS resolution work on a Linux machine?

/etc/nsswitch.conf sets the order, usually files then DNS. /etc/hosts is checked first, then the servers in /etc/resolv.conf; on many modern systems that points to systemd-resolved at 127.0.0.53, whose real upstream servers resolvectl status shows. dig name @server queries a specific server to separate a local problem from an upstream one.

Q21. How do you secure SSH on a server?

Use key-based login and set PasswordAuthentication no and PermitRootLogin no in sshd_config, allow only needed users, limit port 22 to known IPs in the firewall or security group, use fail2ban against brute force, and keep the system patched. In the cloud, AWS Systems Manager Session Manager or Azure Bastion can remove the need for open SSH entirely.

Q22. How do you manage a firewall on Linux?

Ubuntu uses ufw (for example ufw allow 443/tcp), Red Hat-based systems use firewalld (firewall-cmd --add-service=https --permanent, then --reload). Both are front ends to the kernel's netfilter, which is configured today with nftables (iptables is the older interface). Always allow your SSH port before enabling a firewall on a remote server.

Disks, LVM and packages

Q23. What is the difference between df and du?

df shows free and used space per mounted file system (df -h for human-readable sizes). du shows how much space files and directories use (du -sh * in a folder). If df shows a full disk but du cannot find the files, a deleted file is probably still held open by a process; lsof +L1 finds it.

Q24. What is LVM, and how do you extend a logical volume?

LVM (Logical Volume Manager) pools physical volumes (disks or partitions) into volume groups and carves logical volumes from them, so storage can be resized without repartitioning. To grow one: add or enlarge a disk, pvcreate it, vgextend the volume group, then lvextend -r -L +10G /dev/vg/lv; the -r flag also grows the file system (ext4 or XFS).

Q25. How do you mount a new disk permanently?

Find it with lsblk, create a partition if needed, make a file system (mkfs.ext4 or mkfs.xfs), create a mount point and mount it. To mount it at boot, add a line to /etc/fstab using the UUID from blkid rather than the device name, then run mount -a to test the entry before rebooting; a wrong fstab line can stop the server from booting.

Q26. How do you install and update packages?

On Debian and Ubuntu: apt update to refresh the package lists, apt install nginx, apt upgrade. On RHEL, Rocky and Amazon Linux 2023: dnf install nginx and dnf update (yum on older versions). Low-level tools are dpkg and rpm. Unattended security updates can be turned on, and the kernel needs a reboot (or live patching) to take effect.

Shell scripting

Q27. What do $?, $#, $@, $0 and $$ mean in a shell script?

$? is the exit status of the last command (0 means success), $# the number of arguments, $@ all arguments as separate words (use "$@" in quotes), $0 the script name, $1 to $9 the positional arguments, and $$ the script's process ID.

Q28. Why do many scripts start with set -euo pipefail?

set -e stops the script when a command fails, -u treats unset variables as errors (catching typos), and -o pipefail makes a pipeline fail if any command in it fails, not just the last. Together they stop a script from carrying on silently after an error, for example deleting files from the wrong directory.

Q29. Write a script that alerts when disk usage is above 80%.

One approach: df -P --output=pcent,target | tail -n +2 | while read -r pct mount; do use=${pct%\%}; if [ "$use" -gt 80 ]; then echo "$mount is at $pct"; fi; done. It skips the header, strips the % sign and compares numbers with -gt. In practice you send the message to email, Slack or a monitoring tool and run the script from cron.

Q30. What is the difference between > , >> , 2>&1 and | ?

> redirects standard output to a file, overwriting it; >> appends. 2> redirects standard error, and 2>&1 sends standard error to wherever standard output goes, so cmd > out.log 2>&1 captures both. | (pipe) sends one command's output as input to the next. /dev/null discards anything written to it.

Troubleshooting scenarios

Q31. A server is very slow. How do you find out why?

Check uptime for load, top or htop for CPU and memory per process, free -h for memory and swap, vmstat 1 for CPU wait and swapping, iostat -x 1 for disk latency, and ss or iftop for network. dmesg and journalctl show OOM kills or hardware errors. Find which resource is saturated, then which process is using it.

Q32. A website on the server is not loading. What do you check?

Work layer by layer: is the service running (systemctl status nginx) and listening (ss -tlpn)? Does curl localhost work on the server? Does DNS resolve to the right IP? Do the firewall and the cloud security group allow ports 80 and 443? Is the TLS certificate valid? Then read the web server and application error logs for the actual error.

Q33. You get "Permission denied" running a script. What could be wrong?

The file may lack execute permission (chmod +x script.sh, or run it with bash script.sh); the user may lack permission on the file or a parent directory; the file system may be mounted noexec (common for /tmp); SELinux or AppArmor may be blocking it; or the script may have Windows line endings, which gives a "bad interpreter" error that dos2unix fixes.

Q34. How do you find which process is using a port?

ss -tlpn | grep :8080 or lsof -i :8080 shows the process and PID listening on port 8080 (run with sudo to see other users' processes). Then decide whether to stop that process or configure your application to use another port.

Learn Linux hands-on

Knowing the answers is half the job; interviewers also ask what you have built. Technical Guftgu's Linux training is taught in Hindi with live classes, labs and project work, plus resume and mock-interview help. We do not promise or guarantee job placement.

Linux training near you

More interview questions

TECHNICAL GUFTGU

© 2026 Technical Guftgu. All rights reserved.