Preparing for a Linux interview? This comprehensive guide features 30 essential Linux interview questions with detailed answers, progressing from basic to advanced. Ideal for freshers, candidates with 1-3 years, and 3-6 years of experience. Master Linux concepts, practical commands, and real-world scenarios to excel in your next role at companies like Zoho, Paytm, or Atlassian.
Basic Linux Interview Questions
1. What is Linux, and what are its key advantages?
Linux is an open-source operating system kernel that manages hardware resources and provides common services. Key advantages include its stability, security, customizability, and free availability for distribution and modification.[3]
2. How do you check the Linux kernel and operating system version?
Use uname -r to display the kernel version and cat /etc/os-release to view the OS distribution details.[3]
3. What command lists all files, including hidden ones, in a directory?
The command ls -a lists all files, including hidden files that start with a dot (.).[3][4]
4. What is the root account, and why is it significant in Linux?
The root account has UID 0 and full administrative privileges, allowing it to perform any operation on the system. It’s significant for system-wide changes but should be used cautiously.[2][4]
5. Explain the general file system hierarchy in Linux.
The hierarchy starts at / (root): /bin for binaries, /etc for configuration, /home for user directories, /var for variable data like logs, /usr for user programs, and /tmp for temporary files.[4]
6. How do you create a strong password policy in Linux?
Edit /etc/security/pwquality.conf to set minimum length, complexity requirements, and use chage to enforce password aging for users.[3]
7. What does the umask command do in Linux?
umask sets default permissions for newly created files and directories by subtracting from 666 (files) or 777 (directories). Default umask is often 022.[1]
8. How do you view running processes and system load?
Use top or htop for interactive monitoring, uptime for load averages, and ps aux for a process list.[2][5]
9. What command shows free and used memory?
free -h displays memory usage in human-readable format. Free memory does exist in Linux as it’s cached for quick access.[4]
10. How do you update the system and apply security patches?
On Debian-based: apt update && apt upgrade. On RPM-based: dnf update or yum update. Always reboot if kernel updates are applied.[3]
Intermediate Linux Interview Questions
11. How do you manage user accounts and permissions in Linux?
Create users with useradd, set passwords with passwd, modify with usermod, and manage groups via /etc/group. Use chmod and chown for permissions.[2][6]
12. Describe how to secure an SSH server.
Edit /etc/ssh/sshd_config: disable root login (PermitRootLogin no), use key-based auth, change default port, and restart with systemctl restart sshd.[2][3][5]
13. What is swap space, and how do you check it?
Swap is virtual memory on disk used when RAM is full. Check with swapon --show or free -h. It’s important for preventing out-of-memory crashes.[2]
14. How do you configure a firewall using iptables?
Basic rules: iptables -A INPUT -i lo -j ACCEPT, iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT, then drop others. Save with iptables-save.[2][5]
15. Explain how to create an ext4 file system.
mkfs.ext4 /dev/sdX formats the partition. First create partition with fdisk, then format and mount.[1]
16. What are environment variables, and how do you set them?
Variables like PATH that affect process behavior. Set temporarily with export VAR=value, permanently in ~/.bashrc or /etc/environment.[5]
17. How do you monitor system performance and resource usage?
Tools: top, vmstat, sar for historical data (SAR logs in /var/log/sa/), and iostat for disk I/O.[1][2]
18. Describe the process to change the default run level.
Edit /etc/inittab or use systemctl set-default multi-user.target for runlevel 3, or graphical.target for 5.[1]
19. How do you find and kill a zombie process?
Identify with ps aux | grep Z, kill parent with kill -9 PID. Zombies are defunct processes waiting for parent to reap them.[5]
20. What is the difference between hard and soft links?
Hard link: same inode, multiple names to same data. Soft (symbolic) link: separate inode pointing to original path, breaks if target deleted. Create with ln and ln -s.[3]
Advanced Linux Interview Questions
21. What is Logical Volume Manager (LVM), and why use it?
LVM allows dynamic resizing of partitions without downtime. Create PV, VG, LV with pvcreate, vgcreate, lvcreate. Extend with lvextend.[1][5]
22. How would you reduce the size of an LVM partition?
Unmount LV, resize2fs -p /dev/vg/lv 10G to shrink filesystem, then lvreduce -L 10G /dev/vg/lv. Backup first.[1]
23. Explain network bonding modes in Linux.
Mode 0: balance-rr, Mode 1: active-backup, Mode 4: 802.3ad (LACP). Configure in /etc/modprobe.d/bonding.conf and ifcfg-bond0.[1]
24. How do you troubleshoot network connectivity issues?
ping for reachability, traceroute for path, ss -tuln or netstat for ports, tcpdump for packet capture, check /etc/resolv.conf for DNS.[2][5]
25. What are cgroups, and when would you use them?
cgroups (control groups) limit and monitor resource usage per process group. Use for containers or limiting CPU/memory for services like databases at Paytm.[4]
26. How do you implement RAID in Linux?
Software RAID with mdadm: mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc for RAID1.[2][4]
27. Describe backup strategy and disaster recovery.
Level 0 full backups, incremental daily. Tools: rsync, tar. Store offsite, test restores. Automate with cron for /etc, /home.[2][3]
28. How do you compile and install software from source?
./configure, make, make install. Install dependencies first, use checkinstall for packaging.[2]
29. What is a chroot jail, and how do you create one?
chroot changes root directory for a process, isolating it. Create dir structure, copy binaries, chroot /jail /bin/bash. Use for SFTP users.[4]
30. Scenario: At Atlassian, a production server is slow. Outline your troubleshooting steps.
1. Check load with uptime/top. 2. Memory/swap with free. 3. Disk I/O with iostat. 4. Processes with ps. 5. Logs in /var/log. 6. Network with ss. Optimize by killing hogs, tune sysctl.[2][5]
# Example script to clean old logs (from Q30 troubleshooting)
find /var/log -name "*.log" -mtime +7 -exec rm {} \;