Linux Scenario
Linux Scenario
ls -ld /home/username
2. File Permissions: A script is executable by one user but not another. How do you resolve this?
ls -l script.sh
chmod +x script.sh
3. Process Management: A service is consuming 100% CPU. How will you find and fix it?
top or htop
ps aux --sort=-%cpu
4. SSH Issues: You cannot SSH into a remote machine. How do you debug?
sudo iptables -L
5. Disk Space Full: / partition is full. How do you find and delete large files safely?
2. Delete safely:
6. File Corruption: A log file is showing junk characters. How will you check and recover it?
1. Check encoding:
file log.txt
cat -v log.txt
vi log.txt
7. Crontab Not Running: A scheduled job is not executing. How do you debug?
crontab -l
2. Check logs:
chmod +x script.sh
8. Package Installation Failing: yum or apt is failing. How will you resolve it?
ping google.com
lsblk
3. If using LVM:
10. What steps are needed to add a new disk to a Linux server?
lsblk
2. Create a partition:
3. Format it:
4. Mount it:
11. How to check which processes are writing to a file in real time?
iostat -x 1
iotop
14. A directory is taking too much space. How do you analyze it?
du -sh /path/to/directory/*
16. What happens when a file is deleted but is still in use by a process?
2. Secure permissions:
3. Set up swap:
sudo mkswap /swapfile
4. Enable swap:
5. Make it permanent:
18. How do you find large unused files across multiple partitions?
2. Run fsck:
df -i
21. You need to copy a huge file across servers. What's the fastest way?
1. Use rsync:
Check with:
lsof | grep deleted
23. How do you find out which directory is consuming the most in /var?