Posted in

Top 30 Linux Interview Questions and Answers for All Experience Levels

Preparing for a Linux interview? This comprehensive guide features 30 essential Linux interview questions and answers, progressing from basic to intermediate and advanced levels. Ideal for freshers, candidates with 1-3 years of experience, and professionals with 3-6 years in Linux administration. Master core Linux concepts, practical commands, and real-world scenarios to excel in your next interview at companies like Zoho, Atlassian, or Paytm.

Basic Linux Interview Questions

1. What is the Linux kernel and why is it important?

The Linux kernel is the core component of the Linux operating system that manages hardware resources, processes, memory, and system calls. It acts as an interface between applications and hardware, ensuring efficient resource allocation and system stability.[2]

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.[5]

3. What is the name and UID of the administrator user in Linux?

The administrator user is called root with UID 0, which has full system privileges.[3]

4. How do you list all files, including hidden ones, in a directory?

Use ls -la to list all files, including hidden files starting with a dot (.).[3][5]

5. What command shows free and used memory in Linux?

The free -h command displays memory usage in a human-readable format. Free memory does exist in Linux as cached or buffer memory available for new processes.[3]

6. Explain the general file system hierarchy of a Linux system.

Linux follows the Filesystem Hierarchy Standard (FHS): / is root, /etc for configuration, /home for user data, /var for variable files like logs, /usr for user applications, and /tmp for temporary files.[3]

7. What does CTRL+C do in a Linux terminal?

CTRL+C sends a SIGINT signal to terminate the currently running foreground process gracefully.[3]

8. What is in the /etc/services file?

The /etc/services file maps human-readable service names to their port numbers and protocols, used by applications for network communication.[3]

9. How do you check system load averages?

Use uptime or top to view the 1, 5, and 15-minute load averages, which indicate CPU queue length.[3][4]

10. What is the difference between UNIX and Linux?

UNIX is a proprietary OS with closed-source development, while Linux is open-source, UNIX-like, and uses the GNU tools and libraries.[1][3]

Intermediate Linux Interview Questions

11. How do you manage user accounts and permissions in Linux?

Create users with useradd, set passwords with passwd, and manage permissions using chmod for files and chown for ownership. Groups are managed with usermod -G.[2][6]

12. What is the umask command used for in Linux?

umask sets default file creation permissions by subtracting from 666 (files) or 777 (directories). For example, umask 022 creates files with 644 permissions.[1]

13. How would you assign umask to a user permanently?

Add umask 022 to the user’s shell profile file like ~/.bashrc or ~/.profile, depending on their default shell.[1]

14. How do you find and kill a process in Linux?

List processes with ps aux or top, find specific ones with pgrep processname, and terminate with kill PID or killall processname.[4]

15. What is swap space and why is it important?

Swap space is disk storage used as virtual memory when RAM is full. It’s crucial for preventing out-of-memory crashes but impacts performance due to slower disk I/O.[2]

16. How do you redirect STDOUT and STDERR in bash?

Use command > file 2>&1 to redirect both standard output and errors to a file, or command &> file for bash.[3]

17. What are environment variables and how do you set them?

Environment variables configure process behavior. Set them with export VAR=value for the current session or add to ~/.bashrc for persistence.[4]

18. How do you monitor log files in real-time?

Use tail -f /var/log/syslog or journalctl -f for systemd logs to watch logs continuously.[4]

19. Explain how to create an ext4 file system.

Format a partition with mkfs.ext4 /dev/sdX, then mount it using mount /dev/sdX /mountpoint and add to /etc/fstab for persistence.[1]

20. What is LILO and how does it differ from GRUB?

LILO (Linux Loader) is a legacy boot loader requiring manual configuration after kernel changes. GRUB is more flexible with dynamic module loading and editing boot parameters.[1][2]

Advanced Linux Interview Questions

21. What is Logical Volume Manager (LVM) and why is it required?

LVM provides flexible disk management by abstracting physical volumes into logical ones, allowing resizing volumes without downtime and easy snapshots.[1]

22. How would you reduce the size of an LVM partition?

Unmount the filesystem, use lvreduce -L 10G /dev/vg/lv, resize the filesystem with resize2fs, then remount.[1]

23. Where are SAR logs stored and how do you check CPU statistics?

SAR (System Activity Reporter) logs are in /var/log/sa/. Check CPU stats with sar -u or memory with sar -r.[1]

24. What are the different network bonding modes in Linux?

Common modes include mode 0 (balance-rr), mode 1 (active-backup), mode 4 (802.3ad LACP). Configure in /etc/network/interfaces or NetworkManager.[1]

25. How do you configure iptables for network security?

Define rules with iptables -A INPUT -p tcp --dport 22 -j ACCEPT, save with iptables-save > /etc/iptables.rules, and load on boot.[2][4]

Scenario-Based Linux Interview Questions

26. At Atlassian, how would you troubleshoot a slow Linux system?

Check load with top or uptime, memory with free -h, I/O with iostat, and processes with ps aux --sort=-%cpu to identify bottlenecks.[2][4]

27. Write a bash script to find and delete .log files older than 7 days in /var/log.

#!/bin/bash
find /var/log -name "*.log" -mtime +7 -exec rm {} \;

This script uses find with -mtime +7 to locate and delete old log files safely.[2]

28. In a Zoho server scenario, how do you recover a deleted file?

If the filesystem is ext3/4, use extundelete --restore-file /path/to/file or check lsof if a process still holds it. Always rely on backups as primary recovery.[4]

29. How would you secure password files in a Paytm Linux environment?

Shadow passwords are in /etc/shadow with 0000 permissions. Use strong password policies via PAM, enforce authconfig, and restrict access with SELinux.[1][2]

30. For a high-availability setup at Salesforce, explain RAID configurations.

RAID 0 stripes for speed, RAID 1 mirrors for redundancy, RAID 5 parity for capacity, RAID 10 combines 1+0. Implement with mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e].[3]

Leave a Reply

Your email address will not be published. Required fields are marked *