๐Ÿง Top 20 Linux Interview Questions and Answers for Freshers & Experienced (2025)

โœ… 1. How to Set a User Password to Never Expire in Linux?

Command:

chage -M -1 <username>

This sets the password to never expire, ensuring uninterrupted system access for service or system users.


โœ… 2. Why Are /etc/passwd and /etc/shadow Kept Separate?

  • /etc/passwd: Stores non-sensitive user data, world-readable.
  • /etc/shadow: Stores encrypted passwords, root-only access.
    ๐Ÿ‘‰ This enhances Linux user account security by isolating sensitive password hashes.

โœ… 3. How to List All Open Files by a Process in Linux?

Command:

lsof -p <PID>

Use this to find open files and sockets used by a specific process. Useful in troubleshooting I/O and locking issues.


โœ… 4. Why Canโ€™t You Unmount a Filesystem?

Common reasons:

  • Directory is in use: pwd
  • Users are active: fuser -cu /mountpoint
  • Files are open: lsof /mountpoint

โœ… 5. Why Does the Server Boot Slowly After a Reboot?

If the filesystem is ext2, it lacks journaling. After a crash, it triggers full fsck, causing delays.


โœ… 6. Getting “Permission Denied” But Space and Permissions Are Fine?

Check for inode exhaustion:

df -i

Inodes are essential for file metadata; 100% inode usage can prevent file creation even if space is available.


โœ… 7. How to Check Kernel Routing Table in Linux?

Commands:

route -n
netstat -rn
ip route

These display Linux routing table entries for network debugging.


โœ… 8. What Is Sticky Bit? How to Set It?

Only file owners or root can delete files inside a Sticky Bit directory:

chmod +t /dir
# OR
chmod 1757 /dir

โœ… 9. How to Extend a Logical Volume (LVM) and Filesystem?

lvextend -L +1G /dev/vgname/lvname
resize2fs /dev/vgname/lvname

Used to dynamically resize volumes in LVM-based Linux systems.


โœ… 10. How to Roll Back a Yum/DNF Package After Patching?

yum history undo <ID>      # RHEL 7
dnf history undo <ID> # RHEL 8/9

โœ… 11. Difference Between df and du in Linux?

  • df: Shows disk usage from metadata (fast).
  • du: Walks the directory to sum file sizes (accurate).
    ๐Ÿ‘‰ Use du for directory-level usage, df for overall partition space.

โœ… 12. How to Scan for New Disks Without Rebooting?

echo "---" > /sys/class/scsi_host/host0/scan

โœ… 13. How to Check Listening Ports in Linux?

netstat -anp | grep <port>
# Or
ss -tuln

โœ… 14. How to Safely Reduce an LVM Volume?

  1. Unmount the LV
  2. Check FS: e2fsck -f /dev/vg/lv
  3. Resize FS: resize2fs
  4. Reduce: lvreduce -L 1G

โœ… 15. How to Kill a Process from top?

While in top, press k, enter the PID and signal (default: 15, use 9 for force kill).


โœ… 16. How to Check Who Rebooted the Server?

last reboot
# Check logs
cat /var/log/messages

โœ… 17. What Are SUID, SGID, and Sticky Bit in Linux?

  • SUID: Run as file owner
  • SGID: Run as file group
  • Sticky Bit: Restricts delete access in shared directories

โœ… 18. How to Grant Sudo Access to a User Temporarily?

visudo

Add:

username ALL=(ALL) ALL

๐Ÿ‘‰ Grants temporary root access via sudo.


โœ… 19. How to Migrate LVM Data from One Physical Volume to Another?

pvmove /dev/sdX /dev/sdY

Transfers data from old to new physical volume without downtime.


โœ… 20. How to Troubleshoot a Full /opt Even After Deleting Files?

Check if any process is holding deleted files:

lsof | grep /opt

Kill the process using: kill -9 <PID>

Engr. Abhishek Roshan

Engr. Abhishek Roshan

Leave a Reply

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

Author Info

John Deo

John Deo

Lorem ipsum dolor sit amet consectetur adipiscing elit, molestie habitasse vivamus praesent tempor a lectus mus, egestas venenatis imperdiet arcu accumsan montes. Natoque taciti congue donec eros montes at nisi posuere class sapien tristique, sociosqu

Hot Topics

View All
error: Content is protected !!