Prepare for your next Linux role at companies like Amazon, Zoho, or Atlassian with these 30 essential Linux interview questions. This guide covers basic, intermediate, and advanced topics, perfect for freshers, 1-3 years, and 3-6 years experienced candidates. Each question includes clear, practical answers to help you succeed.
Basic Linux Interview Questions (Freshers & 1-3 Years)
1. What command checks the Linux kernel and operating system version?
To check the kernel version, use uname -r. For the full OS details, run cat /etc/os-release or lsb_release -a. These commands display distribution-specific information like Ubuntu 22.04 or CentOS 8.[1]
2. How do you list all files, including hidden files, in a directory?
Use ls -la to list all files, including hidden ones starting with a dot (.). The -l flag shows detailed permissions, owner, and size.[1][3]
3. What is the name and UID of the administrator user in Linux?
The default administrator is root with UID 0. Verify with id root or check /etc/passwd.[3]
4. How do you create a new directory and set its permissions?
Create a directory with mkdir /path/to/newdir. Set permissions using chmod 755 /path/to/newdir for owner read/write/execute and others read/execute.[5]
5. What does the umask command do in Linux?
umask sets default permissions for new files and directories by subtracting from 666 (files) or 777 (directories). Default umask 022 creates files with 644 permissions.[2]
6. How do you check free and used memory in Linux?
Use free -h to display memory usage in human-readable format. It shows total, used, free, and available RAM.[3]
7. What command shows active users logged into the system?
Run who or w to list logged-in users, their terminals, and activity.[5]
8. How do you search for a string in files recursively in a directory?
Use grep -r "string" /path/to/directory to search recursively.[3]
9. What is in the /etc/services file?
/etc/services maps service names to ports and protocols, like port 22 for SSH.[3]
10. What are the three load averages in Linux and how do you view them?
Load averages (from uptime or top) show system load over 1, 5, and 15 minutes. Values above CPU cores indicate high load.[3]
Intermediate Linux Interview Questions (1-3 to 3-6 Years)
11. How do you permanently assign umask to a user?
Add umask 022 to the user’s shell profile like ~/.bashrc or ~/.profile. Source the file with source ~/.bashrc.[2]
12. Explain Logical Volume Manager (LVM) and why it’s used.
LVM allows dynamic resizing of partitions without downtime. Create with pvcreate, vgcreate, lvcreate. Extend with lvextend.[2]
13. How do you reduce the size of an LVM partition?
Unmount the filesystem, run resize2fs /dev/mapper/vg-lv 10G to shrink, then lvreduce -L 10G /dev/mapper/vg-lv. Always backup first.[2]
14. Where are kernel modules located in Linux?
Kernel modules are in /lib/modules/$(uname -r)/. List with lsmod or load with modprobe.[2]
15. What are network bonding modes in Linux?
Bonding combines interfaces for redundancy/load balancing. Mode 0 (balance-rr), Mode 1 (active-backup), Mode 4 (802.3ad LACP). Configure in /etc/network/interfaces.[2]
16. How do you create an ext4 filesystem on a partition?
Run mkfs.ext4 /dev/sdX1 after partitioning with fdisk. Then mount with mount /dev/sdX1 /mnt.[2]
17. What is a chroot jail?
chroot changes root directory for a process, isolating it for security, like in SFTP. Use chroot /path newroot /bin/bash.[3]
18. How do you find which process holds a busy mount point?
When umount fails as “busy”, use lsof /mount/point or fuser -m /mount/point to find PIDs, then kill them.[3]
19. What are cgroups in Linux?
cgroups (control groups) limit and monitor resource usage like CPU/memory for processes. Used in containers. Manage with cgcreate, cgexec.[3]
20. How do you redirect STDOUT and STDERR in bash?
Redirect both to null: command > /dev/null 2>&1. STDOUT to file: > file, STDERR: 2> file.[3]
Advanced Linux Interview Questions (3-6 Years)
21. How would you enhance security of password files in Linux?
Secure /etc/shadow with chmod 600, use strong hashing like SHA-512 in /etc/login.defs, and enforce password policies with PAM.[2]
22. Describe the Linux boot process with systemd.
BIOS/UEFI loads GRUB bootloader, which loads kernel and initramfs. systemd (PID 1) starts targets, services via .service files.[1]
23. How do you control systemd services on a remote server?
Use systemctl start/stop/restart service. For remote: ssh user@host systemctl restart nginx.[1]
24. What is LD_PRELOAD and when is it used?
LD_PRELOAD loads a library before others, overriding functions for debugging/troubleshooting. Example: LD_PRELOAD=/path/lib.so program.[3]
25. How do you increase or decrease process priority in Linux?
Use nice -n 10 command for new processes (higher nice = lower priority). For running: renice 10 -p PID.[3]
26. Scenario: A binary runs but does nothing. How do you debug?
Check with strace binary for syscalls, ldd binary for libraries, lsof -p PID for open files, and environment variables.[3]
27. How do you set up NFS to share a directory?
On server: Edit /etc/exports with /share 192.168.1.0/24(rw,sync), run exportfs -a, start nfs-server. Client: mount server:/share /mnt.[2]
28. What steps secure a Linux production server at Paytm?
Update with apt/yum update, configure SSH key auth, firewall with iptables/ufw, disable unused services, enable SELinux, regular backups, and log monitoring.[1]
29. Scenario: Handle high load on a Salesforce Linux server. What do you do?
Check top/htop for top processes, iotop for disk I/O, vmstat for metrics. Kill offenders, tune sysctl.conf for swappiness, add resources via cgroups.[1][3]
30. How do you implement backup strategy for critical SAP Linux systems?
Use rsync for incremental, tar for full, cron for scheduling. Store offsite, test restores, document recovery with LVM snapshots.[1]