Back to sections

Linux Interview Questions & Answers

A sample of real Linux interview questions with full answers and explanations - practice for interviews or certification exams.

easy

1. You downloaded a large ISO from two different mirrors and need to confirm they're byte-for-byte identical. What's the standard way to verify this quickly?

Run cat on both and see if the terminal looks the same
Open both in a text editor and scroll through
Compare file sizes with ls -l only
Compare sha256sum output for both filesCorrect

Matching file sizes alone doesn't guarantee the CONTENTS are identical, corruption can happen without changing a file's size. A cryptographic checksum like sha256sum produces a unique fingerprint of the actual content, so comparing those fingerprints is the fast, reliable way to confirm two large files are truly byte-for-byte the same.

medium

2. A volume group has no free space, but a new physical disk was just attached to the server. The logical volume's filesystem needs to grow. What's the correct sequence?

Format the new disk separately and mount it at a new path instead
Delete the LV and recreate it larger
pvcreate the new disk, vgextend the VG with it, lvextend the LV, then resize2fs/xfs_growfsCorrect
Immediately run resize2fs on the existing LV

LVM is a stack of layers, physical volume, then volume group, then logical volume, and each layer has to actually include the new disk's space before the one above it can use it. Trying to resize the filesystem first would fail outright, since the logical volume underneath it hasn't actually grown yet to give it anything to expand into.

hard

3. A growing fleet of servers needs consistent internal name resolution, but a script that pushes /etc/hosts to every machine is becoming error-prone and hard to keep in sync. What's the correct enterprise-appropriate fix?

Have every server query every other server's /etc/hosts directly
Hardcode IP addresses into every application config instead of hostnames
Stand up (or point to) a proper internal DNS service instead of distributing static hosts filesCorrect
Write a more reliable script that pushes /etc/hosts more frequently

Manually pushing a static hosts file to every server works for a handful of machines, but it falls apart as the fleet grows, every single change means re-pushing everywhere, and it's easy for things to quietly drift out of sync. A real internal DNS service is built exactly to solve this at scale, one place to update, and every server just looks it up.

easy

4. What does ip addr show display that ifconfig does not?

MAC address
master/slave bonds, VRFs, and NO-CARRIER statusCorrect
IPv6 addresses
Interface state (UP/DOWN)

ip addr is the modern replacement for the older, now-deprecated ifconfig, and it exposes a lot more of what the kernel actually tracks, like whether an interface is part of a bond, belongs to a VRF, or has no physical link detected at all (NO-CARRIER), details ifconfig was never updated to show.

medium

5. What does SO_REUSEADDR vs SO_REUSEPORT do for a TCP server?

REUSEADDR enables keepalive
REUSEPORT disables Nagle’s algorithm
EUSEADDR: allows bind to TIME_WAIT sockets; REUSEPORT: allows multiple identical binds (for multi-process load balancing)Correct
Both do the same thing

These sound similar but solve different problems: REUSEADDR just lets a NEW process bind to a port that's still lingering in TIME_WAIT from an old one that used it, while REUSEPORT lets MULTIPLE processes bind that exact same port AT THE SAME TIME, with the kernel spreading incoming connections across all of them, which is how you'd run several worker processes load-balancing one port.

hard

6. Different teams need different, restricted sudo command sets (e.g. devops can restart services but not manage users) without maintaining a separate sudoers line per person. What's the correct structure?

Write one giant sudoers line manually listing every username
Define a Cmnd_Alias for each command set and assign it to the relevant %group in /etc/sudoers or a file under /etc/sudoers.d/Correct
Give every user in every team full NOPASSWD:ALL to keep things simple
Create a new Linux user account shared by the whole team

A Cmnd_Alias lets you define a named set of commands once (like 'service-restarts'), and then grant that whole set to a group in one line, so as teams and permissions grow, you're managing a handful of clean rules instead of either one giant unmaintainable list of individual users, or worse, giving everyone blanket full access just to avoid the hassle.

easy

7. How do you find which process is holding a deleted (but still open) file?

lsof +L1Correct
find / -inum <inode>
fuser -v /path
stat /path

When a file gets deleted while a process still has it open, Linux doesn't actually free the disk space, it just removes the name from the directory listing. lsof +L1 specifically shows you files like that, ones a process is still holding open even though their link count has dropped to zero, which is exactly how you'd notice disk space that 'should' be free but isn't.

medium

8. What is the purpose of arping -I eth0 192.168.1.1?

Flushes ARP cache
Measures latency
Verifies Layer 2 connectivity (MAC resolution) when ICMP is blockedCorrect
Scans for open ports

arping works entirely below the IP layer, it sends a raw ARP request and waits for a MAC address to reply, so it doesn't rely on ICMP (what ping uses) at all. That makes it a reliable way to confirm a device is present on the local network segment even when a firewall is specifically blocking ping.

hard

9. An application needs a higher open-file-descriptor limit permanently, not just for the current shell session. Why doesn't running `ulimit -n 65536` at the shell solve this properly, and what's the correct fix?

ulimit -n is deprecated and no longer works on any modern distro
ulimit set that way only affects the current shell and its children; persist it via /etc/security/limits.conf (or a drop-in under limits.d/) insteadCorrect
File descriptor limits cannot be changed on Linux at all
The correct fix is always to recompile the kernel with new defaults

Running ulimit interactively only changes the limit for THAT shell session and whatever it spawns afterward, it's completely forgotten the moment you log out or reboot. To make a higher file-descriptor limit stick permanently for a user or service, it needs to be configured in limits.conf (or the equivalent systemd setting for a service), not set ad hoc in a terminal.

easy

10. A server needs to boot into a text-only login (no GUI) by default going forward. Which command sets this persistently?

telinit 3
systemctl set-default multi-user.targetCorrect
systemctl isolate multi-user.target
init 3

systemctl isolate (or the older init/telinit) only changes what's running RIGHT NOW, it reverts back on the next reboot. set-default is the one that actually updates the persistent symlink deciding what boots every single time going forward, which is what 'by default going forward' actually needs.

Want to practice under real conditions?

Try the full timed Linux quiz.

    Welcome to OpsQuiz!

    Real scenario-based DevOps questions, hands-on practice, and clear explanations for every answer.