Linux Interview Preparation Guide [2025]
Master Linux interviews with this 2025 guide featuring 101 scenario-based questions for IT and DevOps roles. Covering fundamentals, administration, networking, security, scripting, storage, and troubleshooting, it’s tailored for freshers and experienced professionals. Dive into Linux command line interview questions with answers 2025, focusing on Kubernetes, Ansible, and cloud environments. Address real-time Linux scenario-based interview questions 2025 to excel in enterprise settings. Practice Linux administration interview questions for DevOps 2025 to tackle cloud-driven challenges, ensuring success in competitive IT and DevOps interviews with practical, hands-on solutions.
![Linux Interview Preparation Guide [2025]](https://www.devopstraininginstitute.com/blog/uploads/images/202509/image_870x_68b9663a20630.jpg)
Core Linux Concepts
1. What is Linux, and why is it preferred for servers?
Linux is an open-source, Unix-like OS known for stability, security, and flexibility. Preferred for servers due to its cost-effectiveness, customizability, and robust performance in handling workloads like web hosting or databases.
2. What are the key components of a Linux system?
-
Kernel: Manages hardware, processes, memory.
-
Shell: User interface (e.g., Bash, Zsh).
-
File System: Organizes data (e.g., ext4, XFS).
-
Utilities: Commands like ls, grep.
-
Libraries: Shared code (e.g., glibc).
These ensure efficient system operation.
3. How do Linux distributions differ, and which are common in 2025?
Distributions (e.g., Ubuntu, RHEL, Alpine) vary in package managers, release cycles, and use cases. Ubuntu is user-friendly, RHEL is enterprise-focused, Alpine is lightweight for containers. Choose based on workload (e.g., Alpine for Docker).
4. How do you check the Linux distribution and kernel version?
-
cat /etc/os-release: Shows distro (e.g., Ubuntu 24.04 LTS).
-
uname -r: Kernel version (e.g., 6.5.0-21-generic).
Ensures compatibility and aids debugging.
5. What is a shell, and why is it critical for automation?
A shell (e.g., Bash) interprets commands and supports scripting. Critical for automating tasks like backups or deployments in DevOps pipelines.
6. What is the difference between a process and a thread?
-
Process: Independent program with own memory (e.g., nginx).
-
Thread: Lightweight unit within a process, sharing memory.
View: ps -eLf. Processes are isolated, threads are faster.
7. What is the /etc directory’s purpose?
Stores system configuration files (e.g., /etc/passwd for users, /etc/fstab for mounts). Essential for system and service setup.
8. How does Linux manage process scheduling?
Uses the Completely Fair Scheduler (CFS) for preemptive multitasking. Adjust priorities with nice (e.g., nice -n 10 script.sh) or chrt for real-time tasks.
9. What is the root user, and how is it secured?
Root (UID 0) has full system access. Secured via sudo, disabling root SSH (PermitRootLogin no in /etc/ssh/sshd_config), and key-based authentication.
10. What is the /proc filesystem, and how is it used?
Virtual filesystem with runtime data (e.g., /proc/cpuinfo for CPU details). Used for monitoring system resources in real-time.
File System and Storage
11. What is the Filesystem Hierarchy Standard (FHS)?
Defines directory roles: /bin (binaries), /home (user files), /var (logs), /tmp (temporary). Ensures consistency across distros.
12. What are common Linux filesystems, and their use cases?
-
ext4: General-purpose, reliable for servers.
-
XFS: High-performance for large datasets.
-
Btrfs: Snapshots, ideal for backups.
-
ZFS: Advanced features for container storage.
Example: Use Btrfs for CI/CD snapshotting.
13. How do you check disk usage?
-
df -h: Filesystem usage (e.g., /dev/sda1: 60G used).
-
du -sh /path: Directory usage.
Critical for capacity planning.
14. How does Logical Volume Manager (LVM) work?
Manages storage dynamically:
-
Physical Volumes (PVs): Disks/partitions.
-
Volume Groups (VGs): PV pools.
-
Logical Volumes (LVs): Virtual partitions.
Example: lvcreate -L 20G -n data vg1.
15. How do you create a new filesystem?
fdisk /dev/sdb # Create partition
mkfs.ext4 /dev/sdb1
mount /dev/sdb1 /mnt
echo "/dev/sdb1 /mnt ext4 defaults 0 2" >> /etc/fstab
Verify: df -h.
16. What is the difference between hard and soft links?
-
Hard Link: Shares inode, same data (e.g., ln file1 file2).
-
Soft Link: Points to path (e.g., ln -s file1 link1).
Hard links persist after original deletion; soft links break.
17. How do you repair a corrupted filesystem?
Unmount: umount /dev/sda1, run: fsck.ext4 -y /dev/sda1. Backup first. Verify: mount.
18. What is swap space, and how do you configure it?
Extends RAM on disk:
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Add to /etc/fstab: /swapfile swap swap defaults 0 0. Verify: free -h.
19. How do you mount a remote NFS share?
apt install nfs-common
mount -t nfs server:/export /mnt
Persist: /etc/fstab, server:/export /mnt nfs defaults 0 0. Verify: df -h.
20. What is mdadm for RAID?
Manages software RAID. Example:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
mkfs.ext4 /dev/md0
Verify: cat /proc/mdstat.
System Administration
21. How do you check system uptime?
uptime
Shows 5 days, 2:15. Tracks server reliability.
22. What is /etc/passwd used for?
Stores user details: username, UID, GID, home, shell (e.g., user:x:1000:1000:/home/user:/bin/bash). Edited via useradd.
23. How do you add a user for a service?
useradd -m -s /bin/bash appuser
passwd appuser
Verify: id appuser. Used for CI/CD accounts.
24. How do you change file permissions?
chmod 644 file # Owner: rw, others: r
chmod u+x script.sh # Add execute for owner
Verify: ls -l.
25. What is umask, and how does it work?
Sets default permissions (e.g., umask 022 creates files as 644, dirs as 755). Configure in ~/.bashrc.
26. How do you manage services with systemd?
-
Start: systemctl start nginx.
-
Enable: systemctl enable nginx.
-
Status: systemctl status nginx.
Example: systemctl restart docker.
27. How do you schedule a recurring task?
Edit: crontab -e:
0 2 * * * /backup.sh
Runs daily at 2 AM. Verify: crontab -l.
28. What is the /root directory?
Root user’s home directory for configs and scripts (e.g., /root/.bashrc). Restricted to root.
29. How do you terminate a process?
Find PID: ps aux | grep process, kill: kill -9 <PID>. Example: kill -9 1234. Verify: ps.
30. What is systemd-analyze for?
Analyzes boot performance:
-
systemd-analyze: Total boot time.
-
systemd-analyze blame: Service startup times.
Optimizes server startup.
Networking
31. How do you set a static IP in Ubuntu?
Edit /etc/netplan/01-netcfg.yaml:
network:
ethernets:
eth0:
addresses: [192.168.1.100/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8]
Apply: netplan apply. Verify: ip addr.
32. What is /etc/hosts used for?
Maps IPs to hostnames (e.g., 192.168.1.10 server.local). Used for local DNS resolution.
33. How do you troubleshoot network issues?
-
Check interface: ip link.
-
Test connectivity: ping 8.8.8.8.
-
DNS: dig google.com.
-
Ports: ss -tuln.
Example: Fix missing nameserver in /etc/resolv.conf.
34. How do you configure firewalld?
firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --reload
Opens port 8080. Verify: firewall-cmd --list-all.
35. How do you secure SSH access?
Edit /etc/ssh/sshd_config:
-
Port 2222
-
PermitRootLogin no
-
PasswordAuthentication no
Copy keys: ssh-copy-id. Restart: systemctl restart sshd.
36. What is nftables vs. iptables?
-
nftables: Modern, unified firewall with simpler syntax.
-
iptables: Legacy, table-based.
Example: nft add rule ip filter INPUT tcp dport 22 accept.
37. How do you set up a network bond?
Create /etc/sysconfig/network-scripts/ifcfg-bond0 (RHEL):
DEVICE=bond0
BONDING_OPTS="mode=4 miimon=100"
IPADDR=192.168.1.100
NETMASK=255.255.255.0
Restart: systemctl restart network. Verify: ip link.
38. What is nmcli for network management?
Manages NetworkManager. Example:
nmcli con add type ethernet ifname eth0 ipv4.method manual ipv4.address 192.168.1.100/24
Verify: nmcli con show.
39. How do you monitor network traffic?
-
iftop: Real-time bandwidth.
-
tcpdump -i eth0: Packet capture.
Example: iftop -i eth0 for container traffic.
40. What is /etc/resolv.conf?
Lists DNS servers (e.g., nameserver 8.8.8.8). Managed by NetworkManager or edited manually. Verify: nslookup google.com.
Security
41. What is SELinux, and how do you configure it?
Enforces mandatory access controls. Example:
setsebool -P httpd_can_network_connect 1
Allows Apache networking. Check: getenforce.
42. How do you implement two-factor authentication for SSH?
Install: apt install libpam-google-authenticator. Run: google-authenticator. Edit /etc/pam.d/sshd:
auth required pam_google_authenticator.so
Update /etc/ssh/sshd_config: ChallengeResponseAuthentication yes. Restart: systemctl restart sshd.
43. What is ufw, and how do you use it?
Uncomplicated Firewall. Example:
ufw allow 80/tcp
ufw enable
Verify: ufw status.
44. How do you harden a Linux server?
-
Disable root SSH: PermitRootLogin no.
-
Update: apt upgrade.
-
Install fail2ban.
-
Restrict permissions: chmod 600 /etc/passwd.
-
Enable firewall: ufw enable.
45. What is auditd for security?
Logs system events. Configure /etc/audit/audit.rules:
-w /etc/passwd -p wa
Logs changes to /etc/passwd. Check: ausearch -f /etc/passwd.
46. How do you limit SSH access by IP?
Edit /etc/ssh/sshd_config:
ListenAddress 192.168.1.100
Or firewalld: firewall-cmd --add-source=192.168.1.0/24 --permanent. Restart: systemctl restart sshd.
47. What is chroot jail?
Isolates processes to a directory. Example:
chroot /jail /bin/bash
Used for secure service isolation.
48. How do you check for security updates?
-
Ubuntu: apt list --upgradable.
-
RHEL: dnf check-update --security.
Apply: apt upgrade or dnf update.
49. What is pam_limits.so?
Sets resource limits in /etc/security/limits.conf. Example:
appuser hard nproc 100
Limits appuser to 100 processes.
50. How do you rotate SSH keys?
Generate: ssh-keygen -f ~/.ssh/newkey. Update ~/.ssh/authorized_keys. Remove old key. Test: ssh -i ~/.ssh/newkey server.
Performance and Monitoring
51. How do you monitor CPU and memory usage?
-
top/htop: Real-time stats.
-
free -h: Memory usage (e.g., used: 3G).
Example: htop identifies high-CPU processes.
52. What is iostat for performance?
Reports disk I/O and CPU. Example: iostat -x 1 5 shows stats every second. High %iowait indicates bottlenecks.
53. How do you check system load?
uptime
Shows 0.5, 0.3, 0.2 (1/5/15 min). Values > CPU cores indicate overload.
54. What is prometheus for monitoring?
Collects metrics for DevOps. Example /etc/prometheus/prometheus.yml:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Uses Node Exporter for system metrics.
55. How do you analyze logs with journalctl?
-
journalctl -u nginx: Nginx logs.
-
journalctl -p 3: Error logs.
-
journalctl -f: Real-time logs.
56. What is glances?
All-in-one monitoring for CPU, memory, disk. Install: apt install glances. Run: glances.
57. How do you check network bandwidth?
-
nload eth0: Real-time traffic.
-
vnstat: Historical usage.
Example: nload for container networks.
58. What is sar used for?
Collects system stats. Example: sar -u 1 5 shows CPU usage. Install: apt install sysstat.
59. How do you identify a high-memory process?
ps aux --sort=-%mem | head
Shows top memory users. Debug with pmap -x <PID>.
60. What is lscpu?
Shows CPU details (e.g., cores, threads). Example: lscpu for performance tuning.
Shell Scripting and Automation
61. How do you write a script to monitor disk usage?
#!/bin/bash
df -h | awk '$5 > 80 {print "Alert: " $6 " at " $5}' | mail -s "Disk Usage" [email protected]
Run: ./disk_monitor.sh.
62. What is a shebang, and why is it used?
Defines interpreter (e.g., #!/bin/bash). Ensures script runs with correct shell.
63. How do you pass arguments to a script?
#!/bin/bash
echo "Server: $1"
Run: ./script.sh webserver.
64. What is sed for text processing?
Edits streams. Example: sed 's/error/warning/g' log.txt replaces “error” with “warning”.
65. How do you use awk for log analysis?
awk '/error/ {print $1}' /var/log/syslog
Prints first column of error lines.
66. What is xargs?
Passes piped input as arguments. Example: find /tmp -name "*.log" | xargs rm deletes logs.
67. How do you handle errors in scripts?
cp file.txt /backup || { echo "Failed"; exit 1; }
Exits on failure, logs to /var/log/script.log.
68. What is a here document?
Passes multi-line input. Example:
cat << EOF > config.txt
Setting=value
EOF
69. How do you debug a script?
Use bash -x script.sh for tracing or add set -x in script. Example: Shows executed commands.
70. What is Ansible for automation?
Manages configurations via YAML. Example:
- hosts: servers
tasks:
- name: Install nginx
apt: name=nginx state=present
Package Management
71. How do you install a package in RHEL?
dnf install httpd
Verify: rpm -q httpd.
72. What is apt vs. apt-get?
-
apt: User-friendly, high-level.
-
apt-get: Low-level, script-friendly.
Example: apt install nginx.
73. How do you remove unused dependencies?
-
Ubuntu: apt autoremove.
-
RHEL: dnf autoremove.
Frees disk space.
74. What is snap for package management?
Installs sandboxed apps. Example: snap install vlc. Used for cross-distro compatibility.
75. How do you add a repository?
Ubuntu: Edit /etc/apt/sources.list:
deb http://repo.url focal main
Update: apt update. RHEL: /etc/yum.repos.d/custom.repo.
Backup and Recovery
76. How do you back up a directory?
tar -czf /backup/data.tar.gz /data
Restore: tar -xzf data.tar.gz -C /restore.
77. What is rsync for backups?
Synchronizes files. Example:
rsync -av --delete /data /backup
Mirrors /data to /backup.
78. How do you recover a corrupted GRUB?
Boot live USB, chroot:
mount /dev/sda1 /mnt
chroot /mnt
grub-install /dev/sda
update-grub
79. What is a Btrfs snapshot?
Captures filesystem state. Example:
btrfs subvolume snapshot /btrfs/data /btrfs/snap1
Rollback: btrfs subvolume snapshot /btrfs/snap1 /btrfs/data.
80. How do you back up a database?
MySQL: mysqldump -u root -p db > backup.sql.
Restore: mysql -u root -p db < backup.sql.
DevOps and Containers
81. What is Docker, and how do you use it?
Container platform for isolated apps. Example:
docker run -d -p 80:80 nginx
Verify: docker ps.
82. How do you create a Dockerfile?
FROM ubuntu:24.04
RUN apt update && apt install -y nginx
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Build: docker build -t my-nginx ..
83. What is Kubernetes?
Orchestrates containers. Example: Deploy nginx:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 2
template:
spec:
containers:
- name: nginx
image: nginx:latest
84. How do you check container resource usage?
docker stats
Or Kubernetes: kubectl top pod.
85. What is Podman?
Rootless container tool, no daemon. Example: podman run -d nginx. More secure than Docker.
Troubleshooting and Diagnostics
86. How do you troubleshoot high CPU usage?
Use top or htop. Example: ps aux --sort=-%cpu lists top processes. Debug: strace -p <PID>.
87. What is dmesg?
Shows kernel logs. Example: dmesg | grep -i error finds hardware issues.
88. How do you troubleshoot a failed service?
Check: systemctl status nginx. Logs: journalctl -u nginx. Restart: systemctl restart nginx.
89. What is tcpdump?
Captures packets. Example: tcpdump -i eth0 port 80 logs HTTP traffic.
90. How do you recover a deleted file in use?
Find: lsof | grep file, copy: cp /proc/<PID>/fd/<fd> /restore/file.
CI/CD and Automation
91. How do you set up a Jenkins pipeline?
Create Jenkinsfile:
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'make build'
}
}
}
}
92. What is GitLab CI?
Automates CI/CD. Example .gitlab-ci.yml:
build:
script:
- make build
93. How do you use Terraform?
Manages infrastructure. Example:
resource "aws_instance" "server" {
ami = "ami-12345678"
instance_type = "t2.micro"
}
94. What is ansible-playbook?
Runs Ansible tasks. Example:
ansible-playbook -i hosts playbook.yml
95. How do you monitor with Prometheus?
Configure /etc/prometheus/prometheus.yml:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Advanced Topics
96. What is eBPF?
Extends kernel for networking and monitoring. Example: Used by cilium for Kubernetes observability.
97. What is systemd-nspawn?
Lightweight containerization. Example:
systemd-nspawn -D /container
98. What is cgroups?
Manages resource limits for processes/containers. Example: /sys/fs/cgroup/cpu/docker limits container CPU.
99. How do you enable IPv6?
Edit /etc/sysconfig/network-scripts/ifcfg-eth0 (RHEL):
IPV6INIT=yes
IPV6ADDR=2001:db8::1/64
Test: ping6 ipv6.google.com.
100. What is logrotate?
Manages log files. Example /etc/logrotate.d/nginx:
/var/log/nginx/*.log {
daily
rotate 7
compress
}
101. What skills are essential for Linux roles in 2025?
-
Automation: Bash, Ansible, Terraform.
-
Containers: Docker, Kubernetes, Podman.
-
Monitoring: Prometheus, Grafana.
-
Networking: ip, firewalld, IPv6.
-
Security: SELinux, fail2ban.
-
Cloud: AWS, Azure integration.
Tips to Ace Linux Interviews
-
Hands-On Practice: Use VirtualBox or cloud platforms to master commands and setups.
-
Scripting: Automate tasks like backups or monitoring.
-
Explain Clearly: Simplify concepts like LVM or Kubernetes for interviewers.
-
Stay Current: Learn 2025 trends (eBPF, Podman, cloud-native).
-
Certifications: Pursue RHCSA, LFCS, or CKA for credibility.
-
Simulate Scenarios: Practice troubleshooting (e.g., network failures, container crashes).
What's Your Reaction?






