Linux interview questions for DevOps roles:
1. Basic Linux Commands
What are some commonly used Linux commands in DevOps?
o ls, cd, pwd, cp, mv, rm, cat, echo, grep, find, awk, sed, tar, zip, unzip
How do you check disk usage and memory consumption in Linux?
o Use df -h for disk usage and free -m for memory consumption.
What is the difference between df -h and du -sh?
o df -h shows disk usage of file systems, while du -sh shows the disk usage of
a specific directory.
How do you find a file in Linux? (e.g., using find or locate)
o Use find /path -name "filename" or locate filename (after running
updatedb).
How do you count the number of lines in a file?
o Use wc -l filename.
2. User and Permission Management
How do you create a new user and assign them sudo privileges?
o useradd username && passwd username && usermod -aG sudo
username
What are file permissions in Linux? How do you modify them using chmod,
chown, and chgrp?
o Use chmod to change permissions, chown to change file owner, and chgrpto
change group ownership.
How do you find which users are currently logged in?
o Use who, w, or users command.
What is the difference between su and sudo?
o su switches to another user, sudo executes a command as another user.
Explain how Linux groups work and how to add a user to a group.
o Groups manage user permissions; add a user using usermod -aG groupname
username.
3. Process Management
How do you check running processes in Linux?
o Use ps aux, top, or htop.
How do you terminate a process using kill, killall, or pkill?
o Use kill PID, killall process_name, or pkill process_name.
What is the difference between nice and renice?
o nice sets priority for a new process, renice changes priority of a running
process.
How do you check CPU and memory usage of a process?
o Use top, htop, or ps aux --sort=-%mem | head -5.
What does the top and htop command do?
o top shows running processes, htop is a more user-friendly version of top.
4. Package Management
What is the difference between apt, yum, dnf, and zypper?
o apt (Debian-based), yum & dnf (RHEL-based), zypper (SUSE-based) are
package managers.
How do you install, remove, and update packages in Linux?
o apt install/remove/update package (Debian), yum/dnf
install/remove/update package (RHEL).
How do you find the location of an installed package?
o Use which package or dpkg -L package.
What is the difference between dpkg and rpm?
o dpkg is for Debian-based systems, rpm is for RHEL-based systems.
5. Networking Commands
How do you check open ports in Linux?
o Use netstat -tulnp or ss -tulnp.
What is the difference between netstat and ss?
o ss is faster and more powerful than netstat.
How do you test network connectivity using ping?
o Use ping destination_IP.
How do you check DNS resolution in Linux?
o Use nslookup or dig domain.com.
How do you find your system's IP address?
o Use ip a or hostname -I.
How do you permanently change the hostname of a Linux machine?
o Modify /etc/hostname and restart the system.
o Using this command : hostnamectl set-hostname “vaibhav”
6. Log Management
Where are system logs stored in Linux?
o In /var/log/ directory.
How do you check system logs using journalctl?
o Use journalctl -xe.
How do you filter logs using grep?
o Use grep "keyword" /var/log/syslog.
What is the purpose of /var/log/messages and /var/log/syslog?
o They store system messages and logs.
7. SSH and Remote Access
How do you set up passwordless SSH authentication?
o Use ssh-keygen and ssh-copy-id user@remote-host.
How do you change the default SSH port?
o Modify Port in /etc/ssh/sshd_config and restart sshd.
How do you copy files between servers using scp or rsync?
o scp file user@remote:/path/ or rsync -av file user@remote:/path/.
How do you configure an SSH jump host?
o Use ssh -J user@jumphost user@target-host.
8. Disk Management
How do you check disk partitions in Linux?
o Use lsblk or fdisk -l.
How do you mount and unmount a file system?
o Use mount /dev/sdX /mnt and umount /mnt.
How do you create a new partition using fdisk or parted?
o Use fdisk /dev/sdX, then create partitions interactively.
What is LVM, and how do you create an LVM partition?
o LVM allows flexible disk management; use pvcreate, vgcreate, and
lvcreate.
9. Cron Jobs and Automation
How do you schedule a cron job to run every day at 5 AM?
o Add 0 5 * * * command to crontab -e.
Where are cron jobs stored in Linux?
o In /var/spool/cron/ and /etc/crontab.
What is the difference between cron and anacron?
o cron runs jobs at scheduled times; anacron runs missed jobs.
How do you list all scheduled cron jobs for a user?
o Use crontab -l.
10 System Performance and Troubleshooting
How do you analyze system performance using vmstat, iostat, or sar?
o vmstat: Provides real-time system performance metrics such as CPU usage,
memory, swap, and I/O activity (vmstat 5 10 shows stats every 5 seconds for
10 iterations).
o iostat: Displays CPU and disk I/O statistics (iostat -x 5 provides
extended disk statistics every 5 seconds).
o sar: Collects, reports, and saves system activity (sar -u 5 shows CPU usage
every 5 seconds).
How do you check the system uptime?
o Use the uptime command to display how long the system has been running,
along with load averages.
o Alternative: cat /proc/uptime shows uptime in seconds.
How do you debug a slow server?
o Check CPU and memory usage: top or htop.
o Check disk usage and I/O wait: df -h, du -sh /path, iostat.
oMonitor running processes: ps aux --sort=-%mem or ps aux --sort=-
%cpu.
o Analyze network usage: netstat -tulnp, ss -tulnp, or iftop.
o Check logs for errors: journalctl -xe, dmesg | tail, or
/var/log/syslog.
How do you find the system's load average?
o Use uptime or cat /proc/loadavg to check the 1-minute, 5-minute, and 15-
minute load averages.
o top and htop also display system load averages at the top.
o A load average close to the number of CPU cores indicates full utilization.
11. File Systems and Storage
What is the difference between ext3, ext4, and xfs?
o ext3: Supports journaling, max file size of 2TB, and limited performance.
o ext4: Improved journaling, supports larger file sizes (16TB) and larger
volumes, faster performance.
o XFS: High-performance journaling file system, supports parallel I/O
operations, best for large-scale storage.
How do you check disk space usage using df and du?
o df -h: Shows disk space usage for all mounted filesystems in a human-
readable format.
o du -sh /path/to/dir: Displays the size of a directory and its contents.
How do you format a new disk partition?
o Use mkfs.ext4 /dev/sdX (replace X with the partition name) to format a
partition with ext4.
What is an inode in Linux?
o An inode is a data structure storing metadata about a file (permissions,
ownership, timestamps), but not the filename or actual data.
12. SELinux and Security
What is SELinux? How do you disable it?
o SELinux (Security-Enhanced Linux) is a security module that enforces
mandatory access control policies.
o Disable temporarily: setenforce 0
o Disable permanently: Edit /etc/selinux/config and set
SELINUX=disabled.
How do you check firewall rules in Linux?
o iptables -L -v -n (for older systems)
o firewalld systems: firewall-cmd --list-all
How do you block an IP address using iptables or firewalld?
o iptables: iptables -A INPUT -s <IP> -j DROP
o firewalld: firewall-cmd --permanent --add-rich-rule='rule
family="ipv4" source address="<IP>" reject'
What are the different SELinux modes?
o Enforcing: SELinux policies are enforced.
o Permissive: Policies are not enforced but logged.
o Disabled: SELinux is turned off.
13. Systemd and Service Management
How do you start, stop, restart, and check the status of a service?
o Start: systemctl start <service>
o Stop: systemctl stop <service>
o Restart: systemctl restart <service>
o Status: systemctl status <service>
What is the difference between systemctl and service commands?
o systemctl is used in modern Linux distributions (systemd-based) and
provides more functionality.
o service is used in older distributions that use SysVinit.
How do you enable a service to start at boot?
o systemctl enable <service> ensures the service starts automatically on
boot.
14. Linux Kernel and Boot Process
Explain the Linux boot process step by step.
1. BIOS/UEFI initializes hardware and loads the bootloader.
2. Bootloader (GRUB) loads the kernel into memory.
3. Kernel Initialization sets up device drivers and mounts the root filesystem.
4. init/systemd runs initialization scripts.
5. User Space Initialization starts services and login prompts.
How do you check the current Linux kernel version?
o Use uname -r to display the current kernel version.
How do you update the Linux kernel?
o On Debian-based systems: sudo apt update && sudo apt upgrade -y
o On RHEL-based systems: sudo yum update kernel -y
o Verify with uname -r after reboot.