Linux Interview Questions and Answers

Last Updated : 21 Jul, 2026

Linux is an open-source operating system widely used for servers, cloud computing, cybersecurity, DevOps and embedded systems. It is a fundamental skill for system administrators, developers and security professionals, making it a common topic in technical interviews. It covers:

  • File System: Managing files and directories.
  • Shell Commands: Executing system commands.
  • Users & Permissions: Controlling user access.
  • Processes & Services: Managing running processes and services.
  • Networking: Configuring and troubleshooting networks.

Beginner Level Interview Questions

1. What is the Linux Kernel?

The kernel is the core of Linux. It manages CPU scheduling, memory, hardware devices, processes, networking and file systems.

2. What is the difference between Linux and Unix?

  • Source: Linux is open-source; Unix is mostly proprietary.
  • Cost: Linux is free; Unix is usually commercial.
  • Development: Linux is community-developed; Unix is vendor-developed.
  • Versions: Linux has many distributions; Unix has vendor-specific versions.
  • Examples: Linux - Ubuntu, Debian, Kali | Unix - AIX, HP-UX, Solaris.

3. What is the root user?

The root user is the superuser with unrestricted access to the entire system, including system files, users, services and hardware.

4. What is the difference between CLI and GUI?

Common difference between CLI and GUI:

  • Interface: It uses text commands; GUI uses graphical elements.
  • Performance: It is faster and lightweight; GUI uses more system resources.
  • Automation: It is ideal for scripting and automation; GUI is not.
  • Ease of Use: It requires command knowledge; GUI is more user-friendly.
  • Usage: It is preferred by system administrators and DevOps engineers; GUI is preferred for everyday desktop tasks.

5. What is the Linux file system hierarchy?

Linux organizes files in a hierarchical tree structure starting from the root directory (/). Common directories:

  • /bin: Essential user commands.
  • /etc: Configuration files.
  • /home: User home directories.
  • /var: Variable data (logs, spool).
  • /tmp: Temporary files.
  • /usr: User applications and libraries.

6. What is the difference between an absolute path and a relative path?

The difference between an absolute path and a relative path are:

  • Absolute Path: Starts from the root (/) and specifies the complete file location.
  • Relative Path: Starts from the current working directory.
  • Dependency: Absolute paths are independent of the current location; relative paths depend on it.
  • Example: Absolute - /home/user/file.txt | Relative - Documents/file.txt

The difference between hard link and soft link are:

  • Inode: Hard link shares the same inode; soft link has a different inode.
  • Filesystem: Hard links work only within the same filesystem; soft links can span multiple filesystems.
  • Target: Hard link remains valid if the original file is deleted; soft link becomes broken if the target is deleted.
  • Directories: Hard links are generally not created for directories; soft links can point to both files and directories.

8. What does pwd do?

The pwd (Print Working Directory) command displays the absolute path of the current working directory.

pwd

9. What is an inode?

An inode is a data structure that stores metadata about a file, including permissions, owner, timestamps and disk block locations. It does not store the file name.

10. How do you check the Linux kernel and operating system version?

The kernel version helps verify compatibility, while the operating system version identifies the installed Linux distribution.

uname -r
cat /etc/os-release

11. How do you list all files including hidden files?

Hidden files begin with a dot (.). The ls -la command displays both visible and hidden files along with detailed information.

ls -la

12. What does rm -rf do?

Deletes files and directories recursively (-r) without prompting for confirmation (-f). Use with caution because deletion is permanent.

rm -rf directory_name

13. How do you create a directory?

The mkdir command creates a new directory.

mkdir directory_name

14. How do you search for files?

The find command searches for files and directories based on name, type, size, owner or other attributes.

find /home -name "*.txt"

15. What is the locate command?

Locate searches files using a pre-built database, making it much faster than find.

locate passwd

16. What is command history?

Linux histroy commnad dispalys and stores previously executed commands, allowing users to review and reuse them.

history

17. How do you clear the terminal?

The clear command clears the terminal screen without closing the session.

clear

18. How do you check the current logged-in user?

The whoami command displays the username of the current user.

whoami

19. How do you display system information?

Linux provides multiple commands to display hardware and operating system information.

uname -a
hostnamectl
lscpu
free -h
cat /etc/os-release

20. How do you check disk usage?

Use df command to check filesystem usage and du to check the size of directories or files.

df -h
du -sh /home/user

21. What is the grep command?

grep command searches for text or patterns in files using regular expressions.

grep "error" logfile.txt

22. What do head and tail do?

Head displays the first 10 lines of a file and Tail displays the last 10 lines.

head file.txt
tail file.txt
tail -f logfile.log

23. What is the difference between cat, more and less?

  • cat: Displays the entire file.
  • more: Displays one page at a time (forward only).
  • less: Displays one page at a time (forward and backward).

24. How do you check memory usage?

The free command displays total, used, free and available memory.

free -h

25. A server is slow. Which command do you run first and why?

Top command provides real-time visibility into CPU, memory usage and resource-consuming processes.

top

26. How do you view all running processes?

The ps command displays information about active processes.

ps aux

27. How do you terminate a process in Linux?

The kill command sends signals to terminate a process.

kill PID
kill -9 PID

28. How do you create a new user in Linux?

The useradd command creates a new user and passwd sets the user's password.

sudo useradd username
sudo passwd username

29. What is stored in /var?

/var contains variable data such as: Log files, Mail, Cache, Databases, Print queues.

30. How do you check system uptime and load average?

The uptime command shows how long the system has been running, the number of logged-in users and the system load average.

uptime

31. How do you check the IP address and network interfaces on a Linux system?

The ip addr command displays all network interfaces, their IP addresses and status.

ip addr

32. How do you view system and application logs in Linux?

Linux stores logs under /var/log, while journalctl displays logs managed by systemd

journalctl
less /var/log/syslog

33. What is the touch command in Linux?

The touch command is used to create an empty file or update the access and modification timestamps of an existing file.

touch file.txt

34. What is the difference between cp and mv?

  • cp: Copies files or directories.
  • mv: Moves or renames files or directories.
cp file1.txt backup.txt
mv file1.txt /tmp/

35. What is the cat command?

Cat command Displays, creates or concatenates file contents.

cat file.txt

Intermediate Level Questions

36. What is the difference between a user and a group?

A user is an individual account used to log in to the system. A group is a collection of users used to simplify permission management.

37. What are Linux file permissions?

Linux uses permissions to control access to files and directories. There are three permission types:

  • r (Read): View file contents or list directory contents.
  • w (Write): Modify a file or create/delete files in a directory.
  • x (Execute): Run a file as a program or access a directory.

38. What do the permissions rwxr-xr-- mean?

The permission string is divided into three sets:

  • Owner: rwx(Read, Write, Execute).
  • Group: r-x(Read, Execute).
  • Others: r--(Read only).

39. What is the difference between chmod and chown?

  • chmod: Changes file or directory permissions.
  • chown: Changes the owner and/or group of a file or directory.
chmod 755 file.txt
chown user:group file.txt

40. What are SUID, SGID and Sticky Bit?

SetUID, SetGID and Sticky Bits in Linux File Permissions are:

  • SUID (Set User ID): Executes a file with the owner's privileges.
  • SGID (Set Group ID): Executes a file with the group's privileges or causes new files in a directory to inherit the directory's group.
  • Sticky Bit: Prevents users from deleting files owned by others in a shared directory (e.g., /tmp).
chmod u+s file
chmod g+s directory
chmod +t directory

41. What is the difference between /etc/passwd and /etc/shadow?

  • /etc/passwd: Stores user account information.
  • /etc/shadow: Stores encrypted passwords and password aging information. Accessible only by the root user.

42. What is the difference between a process and a thread?

The difference between a process and a thread is:

  • Process: Independent execution unit with its own memory space.
  • Thread: Lightweight execution unit that shares memory with other threads of the same process.

43. What are nice and renice?

Nice and Renice command in linux:

  • nice: Starts a process with a specified priority.
  • renice: Changes the priority of a running process.
nice -n 10 command
renice 5 -p PID

44. What are jobs, bg and fg?

  • jobs: Lists background jobs.
  • bg: Resumes a suspended job in the background.
  • fg: Brings a background job to the foreground.

45. What is the wget command?

Wget command downloads files from HTTP, HTTPS and FTP servers.

wget https://example.com/file.zip

46. How do you check open ports?

Use the ss command to list listening ports.

ss -tuln

47. How do you remove a package?

Use the package manager to uninstall software.

sudo apt remove package
sudo dnf remove package
sudo pacman -R package

48. How do you update installed packages?

Update the package database and install the latest package versions.

sudo apt update && sudo apt upgrade
sudo dnf update
sudo pacman -Syu

49. What is SSH?

SSH (Secure Shell) is a secure protocol used for remote login, command execution and file transfer over encrypted connections.

ssh user@192.168.1.10

50. What is the difference between SCP and SFTP?

  • SCP: Securely copies files between systems.
  • SFTP: Provides an interactive secure file transfer session.

51. What is the curl command?

Curl command transfers data to or from a server and is commonly used to test APIs and download web content.

curl https://example.com

52. What is the netstat command?

Netstat command displays active network connections, routing tables, interface statistics and listening ports.

netstat -tuln

53. What is dependency management?

Dependency management ensures that all required libraries and packages are automatically installed, updated or removed when managing software packages.

54. How do you install software in Linux?

The command depends on the Linux distribution.

sudo apt install package
sudo dnf install package
sudo pacman -S package

55. How do you permanently mount a filesystem?

A filesystem is permanently mounted by adding its entry to the /etc/fstab file. During boot, Linux reads this file and automatically mounts the listed filesystems.

sudo nano /etc/fstab

Apply changes without rebooting:

sudo mount -a

Advanced Interview Questions

56. Explain the Linux boot process.

Linux boot process follow these steps for booting:

  • BIOS/UEFI initializes hardware.
  • GRUB bootloader loads the Linux kernel.
  • Kernel initializes hardware and mounts the root filesystem.
  • systemd (PID 1) starts system services.
  • User login prompt or GUI is displayed.

57. What is the difference between BIOS and UEFI?

The difference BIOS and UEFI is:

  • BIOS: Legacy firmware, supports MBR (up to 2 TB).
  • UEFI: Modern firmware, supports GPT (>2 TB), Secure Boot and faster startup.

58. What is GRUB?

GRUB (GRand Unified Bootloader) is the bootloader that loads the Linux kernel and allows users to select the operating system during startup. Command:

grub2-mkconfig -o /boot/grub2/grub.cfg

59. What is systemd?

Systemd is the default init system in most Linux distributions. It manages system startup, services, logging and dependencies. Check PID 1:

ps -p 1

60. How do you manage services using systemctl?

Systemctl is used to start, stop, restart, enable, disable and check service status.

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl enable nginx
sudo systemctl status nginx

61. What is the difference between cron and at?

  • cron: Schedules recurring tasks.
  • at: Schedules a one-time task.
crontab -e
at 10:00

62. What is LVM?

LVM (Logical Volume Manager) provides flexible disk management by allowing logical volumes to be resized, extended or reduced without repartitioning.

63. What is swap memory?

Swap is disk space used as virtual memory when physical RAM is exhausted.

swapon --show
free -h

64. What is SELinux and different SELinux modes?

SELinux (Security-Enhanced Linux) is a Mandatory Access Control (MAC) system that restricts processes based on security policies. Different modes:

  • Enforcing: Policies are enforced.
  • Permissive: Violations are logged but not blocked.
  • Disabled: SELinux is turned off.
getenforce

65. How do you troubleshoot high CPU usage?

Identify CPU-intensive processes, then analyze or terminate them if necessary.

top
htop
ps aux --sort=-%cpu

66. What are zombie and orphan processes?

  • Zombie: A terminated process whose parent has not collected its exit status.
  • Orphan: A running process whose parent has terminated. It is adopted by systemd (PID 1).

67. What is the OOM Killer?

The Out-Of-Memory (OOM) Killer is a Linux kernel mechanism that terminates processes when the system runs out of memory to prevent a system crash.

68. A production Linux server is slow. How would you troubleshoot it?

Follow a systematic approach:

  • Check CPU usage (top, htop).
  • Check memory and swap (free -h).
  • Check disk usage (df -h, du -sh).
  • Check load average (uptime).
  • Check running processes (ps aux).
  • Review system logs (journalctl, /var/log).
  • Check network activity (ss, netstat, tcpdump).
  • Identify the root cause and take corrective action.

69. How do you troubleshoot high memory usage?

Check RAM and swap usage, then identify memory-consuming processes.

free -h
top
ps aux --sort=-%mem

70. What is a daemon in Linux?

A daemon is a background process that runs without user interaction and provides system or application services. Examples: sshd, httpd, crond, rsyslogd.

71. What is the difference between RAID 0, RAID 1 and RAID 5?

  • RAID 0: Striping, high performance, no fault tolerance.
  • RAID 1: Mirroring, fault tolerance, 50% usable capacity.
  • RAID 5: Striping with distributed parity, balances performance and fault tolerance.
Comment

Explore