
1️⃣ User Management: A user complains they cannot log in. How will you troubleshoot?
🔍 Steps to resolve: 1️⃣ Check if the user exists:
cat /etc/passwd | grep username
2️⃣ Verify the account is not locked:
sudo passwd -S username
3️⃣ Check failed login attempts:
sudo faillog -u username
4️⃣ Ensure correct permissions for the home directory:
ls -ld /home/username
2️⃣ File Permissions: A script is executable by one user but not another. How do you resolve this?
🔍 Steps to resolve: 1️⃣ Check the script permissions:
ls -l script.sh
2️⃣ Add execute permission if missing:
chmod +x script.sh
3️⃣ Check file ownership:
chown user:user script.sh
3️⃣ Process Management: A service is consuming 100% CPU. How will you find and fix it?
🔍 Steps to resolve: 1️⃣ Identify the process:
top or htop
2️⃣ Get detailed information:
ps aux --sort=-%cpu
3️⃣ Kill or restart the process:
kill -9 PID or systemctl restart service
4️⃣ SSH Issues: You cannot SSH into a remote machine. How do you debug?
🔍 Steps to resolve: 1️⃣ Verify SSH service is running:
sudo systemctl status sshd
2️⃣ Check firewall rules:
sudo iptables -L
3️⃣ Ensure correct permissions for ~/.ssh/authorized_keys 4️⃣ Look for errors in logs:
sudo journalctl -u sshd --since '5 minutes ago'
5️⃣ Disk Space Full: / partition is full. How do you find and delete large files safely?
🔍 Steps to resolve: 1️⃣ Find large files:
sudo du -ah / | sort -rh | head -20
2️⃣ Delete safely:
sudo rm -rf /path/to/large/file
3️⃣ Check open deleted files:
sudo lsof | grep deleted
6️⃣ File Corruption: A log file is showing junk characters. How will you check and recover it?
🔍 Steps to resolve: 1️⃣ Check encoding:
file log.txt
2️⃣ View non-printable characters:
cat -v log.txt
3️⃣ Try opening with vi or nano
7️⃣ Crontab Not Running: A scheduled job is not executing. How do you debug?
🔍 Steps to resolve: 1️⃣ Verify crontab entries:
crontab -l
2️⃣ Check logs:
sudo journalctl -u cron --since '5 minutes ago'
3️⃣ Ensure correct permissions:
chmod +x script.sh
8️⃣ Package Installation Failing: yum or apt is failing. How will you resolve it?
🔍 Steps to resolve: 1️⃣ Clean package manager cache:
sudo apt clean or sudo yum clean all
2️⃣ Check network connection:
ping google.com
3️⃣ Update package lists:
sudo apt update or sudo yum update
🔄 9️⃣ Partition and Disk Management
🔹 Extend a partition without unmounting it:
lsblk
sudo resize2fs /dev/sdX
sudo lvextend -r -L +10G /dev/mapper/vg-lv
🔹 Add a new disk to a Linux server:
lsblk
sudo fdisk /dev/sdX
sudo mkfs.ext4 /dev/sdX1
sudo mount /dev/sdX1 /mnt
🔹 Find which processes are writing to a file in real time:
sudo lsof +f -- /path/to/file
🔹 Recover a deleted file in Linux:
lsof | grep deleted
sudo extundelete /dev/sdX --restore-all
🔹 Check disk I/O performance:
iostat -x 1
iotop
🔹 Analyze which directory is taking up too much space:
du -sh /path/to/directory/*
🔹 Remount a filesystem in read-write mode without rebooting:
sudo mount -o remount,rw /mnt
🔹 Find and delete large unused files:
sudo find / -type f -size +1G -atime +30 -exec ls -lh {} +
🔹 Fix a corrupted file system using fsck:
sudo umount /dev/sdX
sudo fsck -y /dev/sdX
🔹 Resolve inode exhaustion:
df -i
# Delete small unused files
🔹 Copy a huge file across servers quickly:
rsync -avz --progress file user@remote:/destination
scp -C file user@remote:/destination
🔹 Find out which directory is consuming the most in /var:
du -sh /var/* | sort -rh | head -10
💡 Conclusion These scenario-based Linux questions cover real-world troubleshooting situations. Mastering them will make you a strong candidate for Linux admin roles! 🚀
📢 Have more questions or want to share your experience? Drop a comment below! 👇