โ 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).
๐ Usedu
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?
- Unmount the LV
- Check FS:
e2fsck -f /dev/vg/lv
- Resize FS:
resize2fs
- 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>