Linux इंटरव्यू प्रश्न और उत्तर
34 प्रश्न, छोटे और साफ़ उत्तरों के साथ · अपडेट: दिसंबर 2026
Linux लगभग हर क्लाउड और DevOps नौकरी की नींव है, इसलिए इंटरव्यू में इसे शुरुआत में ही परखा जाता है। ये प्रश्न उन विषयों को कवर करते हैं जो एक Linux सिस्टम एडमिनिस्ट्रेटर या DevOps इंजीनियर को आने चाहिए: file system, permissions, processes और systemd, नेटवर्किंग, disk और shell scripting, और आख़िर में ट्रबलशूटिंग सिनेरियो।
पढ़ते समय हर कमांड किसी practice मशीन पर चलाकर देखिए: कमांड जल्दी टाइप कर पाना उतना ही ज़रूरी है जितना उसका काम जानना।
प्रश्न अंग्रेज़ी में रखे गए हैं, क्योंकि इंटरव्यू में ज़्यादातर इसी तरह पूछे जाते हैं। उत्तर हिंदी में हैं, तकनीकी शब्द अंग्रेज़ी में। अंग्रेज़ी उत्तर यहाँ देखें।
Linux की बेसिक बातें और file system
Q1. What is the difference between the Linux kernel and a distribution?
Kernel मुख्य हिस्सा है जो hardware, memory, processes और system calls संभालता है। Distribution (Ubuntu, Red Hat Enterprise Linux, Rocky Linux, Debian, Amazon Linux) kernel के साथ system tools, package manager (apt या dnf), init system (systemd) और default configuration पैक करता है। इंटरव्यू के लिए एक Debian-आधारित और एक Red Hat-आधारित distribution जानिए।
Q2. Explain the main directories in the Linux file system.
/etc में configuration, /var में बदलता डेटा जैसे logs (/var/log) और spools, /home में users की directories, /root में root user का home, /usr में इंस्टॉल प्रोग्राम और लाइब्रेरी, /bin और /sbin में ज़रूरी commands (अब आम तौर पर /usr के link), /tmp में अस्थायी फ़ाइलें, /boot में kernel और bootloader फ़ाइलें, /dev में device फ़ाइलें, /proc और /sys में kernel और process की जानकारी देने वाली virtual फ़ाइलें, और /opt में थर्ड-पार्टी सॉफ़्टवेयर।
Q3. What is an inode?
Inode किसी फ़ाइल की metadata रखता है: owner, permissions, साइज़, timestamps और उसके data blocks की जगह, पर उसका नाम नहीं। Directory entries नामों को inode नंबर से जोड़ती हैं। लाखों छोटी फ़ाइलें होने पर file system में जगह खत्म होने से पहले inodes खत्म हो सकते हैं; df -i inode इस्तेमाल दिखाता है।
Q4. What is the difference between a hard link and a soft link?
Hard link उसी inode का दूसरा नाम है: यह डेटा शेयर करता है, दूसरे file system पर या directory की ओर नहीं जा सकता, और डेटा आख़िरी link डिलीट होने तक बचा रहता है। Soft (symbolic) link एक छोटी फ़ाइल है जिसमें target का path होता है: यह दूसरे file system पर और directory की ओर जा सकता है, पर target हटने या डिलीट होने पर टूट जाता है। इन्हें ln और ln -s से बनाते हैं।
Q5. How do you find files and search text in files?
find नाम, साइज़, समय, owner या type से खोजता है, जैसे find /var/log -name "*.log" -mtime +7 सात दिन से पुराने logs के लिए, और -exec या -delete से नतीजों पर काम कर सकता है। grep फ़ाइलों के अंदर खोजता है, जैसे grep -rin "error" /var/log/nginx; -r recursive, -i case न देखना, -n line नंबर, -v उल्टा, -E extended regex।
Q6. What do awk, sed, cut, sort and uniq do?
awk, text को fields के हिसाब से प्रोसेस करता है, जैसे awk '{print $1}' access.log पहला column दिखाता है। sed stream को edit करता है, जैसे sed -i 's/old/new/g' file। cut, delimiter से columns निकालता है, sort lines को क्रम में लगाता है, और uniq पास-पास की duplicate lines हटाता या गिनता है। मशहूर जोड़: awk '{print $1}' access.log | sort | uniq -c | sort -rn | head सबसे ज़्यादा आने वाले client IP दिखाता है।
Users, permissions और sudo
Q7. Explain Linux file permissions and chmod 755.
हर फ़ाइल पर owner, group और others के लिए read (4), write (2) और execute (1) परमिशन होती हैं। 755 का मतलब owner के पास rwx (7) और group व others के पास r-x (5), जो स्क्रिप्ट और directories के लिए आम है। 644 (rw-r--r--) साधारण फ़ाइलों के लिए आम है। Directory पर x का मतलब उसमें जा सकना और r का मतलब उसकी सूची देख सकना है।
Q8. What are SUID, SGID and the sticky bit?
Executable पर SUID उसे फ़ाइल owner की privileges से चलाता है, जैसे /usr/bin/passwd /etc/shadow अपडेट करने के लिए करता है। Directory पर SGID से नई फ़ाइलें directory का group लेती हैं, टीम के साझा फ़ोल्डर के लिए उपयोगी। Directory पर sticky bit (जैसे /tmp पर) users को सिर्फ़ अपनी फ़ाइलें डिलीट करने देता है। अनपेक्षित SUID फ़ाइलें सिक्योरिटी खतरा हैं; find / -perm -4000 उनकी सूची देता है।
Q9. What is umask?
umask नई फ़ाइलों (666) और directories (777) को मिलने वाली default परमिशन में से परमिशन घटाता है। आम umask 022 पर नई फ़ाइलें 644 और नई directories 755 पाती हैं; 027 पर others को कोई access नहीं मिलता। इसे हर shell या user के लिए सेट किया जाता है, जैसे shell profile या systemd service फ़ाइल में।
Q10. Where are users and passwords stored?
/etc/passwd में accounts (नाम, UID, GID, home directory, shell) होते हैं और इसे सब पढ़ सकते हैं। Password hash /etc/shadow में होते हैं, जिसे सिर्फ़ root पढ़ सकता है, साथ में password की उम्र की सेटिंग। Groups /etc/group में होते हैं। इन्हें useradd, usermod (जैसे usermod -aG docker user), passwd और chage से मैनेज करते हैं।
Q11. How do you give a user limited admin rights?
visudo (जो syntax जाँचता है) से या /etc/sudoers.d में एक फ़ाइल से rule जोड़िए, जैसे deploy user को बिना password सिर्फ़ systemctl restart nginx चलाने देना। पूरा sudo देने के बजाय खास commands देना बेहतर है, और root का SSH login बंद रखिए ताकि admins अपने नाम से login करें और काम लॉग हों।
Q12. What are SELinux and AppArmor?
ये mandatory access control सिस्टम हैं जो किसी process के काम को सीमित करते हैं, चाहे वह root के रूप में चले। SELinux (Red Hat-आधारित सिस्टम पर default) फ़ाइलों और processes पर label लगाकर policy लागू करता है; getenforce mode दिखाता है और audit log में denial दिखते हैं। AppArmor (Ubuntu पर default) हर प्रोग्राम के path-आधारित profile इस्तेमाल करता है। Denial ठीक करने के लिए label या policy सुधारिए, सिस्टम बंद मत कीजिए।
Processes, services और boot
Q13. What is the difference between a process and a thread, and what is a zombie process?
Process की अपनी memory space होती है; threads एक process के अंदर execution की इकाइयाँ हैं जो उसकी memory शेयर करती हैं। Zombie वह process है जो खत्म हो चुका है पर उसके parent ने अभी उसका exit status नहीं पढ़ा; यह CPU या memory नहीं लेता, सिर्फ़ process table की एक entry। बहुत सारे zombie होना parent में bug बताता है; parent के उन्हें collect करने या बंद होने पर वे हट जाते हैं।
Q14. What is the difference between kill, kill -9 and kill -15?
kill डिफ़ॉल्ट रूप से SIGTERM (15) भेजता है, process से साफ़ तरीके से बंद होने को कहता है: फ़ाइलें बंद करना, requests पूरी करना, सफ़ाई करना। kill -9, SIGKILL भेजता है जिसे process पकड़ नहीं सकता, इसलिए वह बिना सफ़ाई तुरंत रुक जाता है और खराब फ़ाइलें या lock छोड़ सकता है। हमेशा पहले SIGTERM आज़माइए और process बंद न हो तभी SIGKILL।
Q15. How do you manage services with systemd?
systemctl start, stop, restart, reload और status से service मैनेज होती है; systemctl enable उसे boot पर शुरू करता है। Unit फ़ाइलें /etc/systemd/system (आपकी) और /usr/lib/systemd/system (packages की) में रहती हैं; किसी को edit करने के बाद systemctl daemon-reload चलाइए। Logs journalctl -u <service> से पढ़े जाते हैं, follow के लिए -f या --since "1 hour ago" जोड़कर।
Q16. What does load average mean?
uptime या top में दिखने वाले तीन नंबर 1, 5 और 15 मिनट में चल रहे या इंतज़ार कर रहे processes (CPU के लिए, और Linux पर disk I/O के लिए भी) की औसत संख्या हैं। इन्हें CPU cores की संख्या (nproc) से मिलाइए: 4-core मशीन पर 4 का load मतलब पूरी तरह इस्तेमाल; उससे बहुत ज़्यादा मतलब काम कतार में है। ज़्यादा load और कम CPU इस्तेमाल आम तौर पर धीमी disk या network storage की ओर इशारा करता है।
Q17. Describe the Linux boot process.
Firmware (UEFI या BIOS) चलकर bootloader (GRUB) ढूँढता है, जो kernel और initramfs लोड करता है। Kernel hardware शुरू करता है, initramfs की मदद से root file system mount करता है, और PID 1 यानी systemd शुरू करता है, जो default target (जैसे multi-user.target या graphical.target) तक पहुँचने के लिए services साथ-साथ शुरू करता है।
Q18. How do you schedule a job in Linux?
cron से: crontab -e में 30 1 * * * /opt/backup.sh (हर दिन 01:30) जैसी lines जोड़िए; पाँच fields हैं minute, hour, महीने का दिन, महीना और हफ़्ते का दिन। पूरे path इस्तेमाल कीजिए और output को log में भेजिए, क्योंकि cron बहुत कम environment के साथ चलता है। आधुनिक विकल्प systemd timers हैं, जिनमें journald से logging और छूटी हुई run संभालने की सुविधा है।
नेटवर्किंग
Q19. Which commands do you use to check network configuration and open ports?
ip addr और ip route से address और routes दिखते हैं (ifconfig और route पुराने हैं); ss -tulpn सुनने वाले TCP और UDP ports उनके processes के साथ दिखाता है (netstat पुराना है); ping से पहुँच जाँचते हैं; traceroute या mtr रास्ता दिखाता है; dig या nslookup से DNS जाँचते हैं; curl -v से HTTP; और nc -zv host port से देखते हैं कि port खुला है या नहीं।
Q20. How does DNS resolution work on a Linux machine?
/etc/nsswitch.conf क्रम तय करता है, आम तौर पर पहले files फिर DNS। पहले /etc/hosts देखा जाता है, फिर /etc/resolv.conf के servers; कई आधुनिक सिस्टम पर यह 127.0.0.53 पर systemd-resolved की ओर होता है, जिसके असली upstream servers resolvectl status दिखाता है। dig name @server किसी खास server से पूछता है, जिससे local समस्या और upstream समस्या अलग पहचानी जाती है।
Q21. How do you secure SSH on a server?
Key से login इस्तेमाल कीजिए और sshd_config में PasswordAuthentication no और PermitRootLogin no सेट कीजिए, सिर्फ़ ज़रूरी users को allow कीजिए, firewall या security group में port 22 को जाने-पहचाने IPs तक सीमित कीजिए, brute force से बचाव के लिए fail2ban लगाइए, और सिस्टम पैच रखिए। क्लाउड में AWS Systems Manager Session Manager या Azure Bastion से खुले SSH की ज़रूरत ही खत्म हो सकती है।
Q22. How do you manage a firewall on Linux?
Ubuntu, ufw इस्तेमाल करता है (जैसे ufw allow 443/tcp), Red Hat-आधारित सिस्टम firewalld (firewall-cmd --add-service=https --permanent, फिर --reload)। दोनों kernel के netfilter के front end हैं, जिसे आज nftables से कॉन्फ़िगर किया जाता है (iptables पुराना interface है)। Remote server पर firewall चालू करने से पहले हमेशा अपना SSH port allow कीजिए।
Disk, LVM और packages
Q23. What is the difference between df and du?
df हर mount हुए file system की खाली और भरी जगह दिखाता है (पढ़ने लायक साइज़ के लिए df -h)। du बताता है कि फ़ाइलें और directories कितनी जगह लेती हैं (किसी फ़ोल्डर में du -sh *)। अगर df disk भरी दिखाए पर du को फ़ाइलें न मिलें, तो शायद कोई डिलीट हुई फ़ाइल अब भी किसी process ने खोल रखी है; lsof +L1 उसे ढूँढता है।
Q24. What is LVM, and how do you extend a logical volume?
LVM (Logical Volume Manager) physical volumes (disk या partition) को volume groups में जोड़ता है और उनसे logical volumes बनाता है, ताकि बिना दोबारा partition किए storage का साइज़ बदला जा सके। बढ़ाने के लिए: disk जोड़िए या बड़ी कीजिए, pvcreate कीजिए, volume group को vgextend कीजिए, फिर lvextend -r -L +10G /dev/vg/lv; -r flag file system (ext4 या XFS) को भी बढ़ा देता है।
Q25. How do you mount a new disk permanently?
lsblk से disk ढूँढिए, ज़रूरत हो तो partition बनाइए, file system बनाइए (mkfs.ext4 या mkfs.xfs), mount point बनाकर mount कीजिए। Boot पर mount करने के लिए /etc/fstab में device नाम के बजाय blkid से मिले UUID के साथ line जोड़िए, फिर reboot से पहले mount -a से entry टेस्ट कीजिए; fstab की गलत line से सर्वर boot होना रुक सकता है।
Q26. How do you install and update packages?
Debian और Ubuntu पर: package सूची ताज़ा करने के लिए apt update, apt install nginx, apt upgrade। RHEL, Rocky और Amazon Linux 2023 पर: dnf install nginx और dnf update (पुराने version में yum)। Low-level टूल dpkg और rpm हैं। Unattended security updates चालू किए जा सकते हैं, और kernel अपडेट लागू होने के लिए reboot (या live patching) चाहिए।
Shell scripting
Q27. What do $?, $#, $@, $0 and $$ mean in a shell script?
$? पिछली command का exit status है (0 मतलब सफल), $# arguments की संख्या, $@ सारे arguments अलग-अलग शब्दों के रूप में (quotes में "$@" लिखिए), $0 स्क्रिप्ट का नाम, $1 से $9 positional arguments, और $$ स्क्रिप्ट का process ID।
Q28. Why do many scripts start with set -euo pipefail?
set -e किसी command के फेल होने पर स्क्रिप्ट रोक देता है, -u बिना सेट variables को error मानता है (typo पकड़ता है), और -o pipefail pipeline को तब फेल करता है जब उसकी कोई भी command फेल हो, सिर्फ़ आख़िरी नहीं। साथ में ये स्क्रिप्ट को error के बाद चुपचाप चलते रहने से रोकते हैं, जैसे गलत directory की फ़ाइलें डिलीट कर देना।
Q29. Write a script that alerts when disk usage is above 80%.
एक तरीका: df -P --output=pcent,target | tail -n +2 | while read -r pct mount; do use=${pct%\%}; if [ "$use" -gt 80 ]; then echo "$mount is at $pct"; fi; done। यह header छोड़ता है, % का निशान हटाता है और -gt से नंबरों की तुलना करता है। असल में संदेश ईमेल, Slack या monitoring टूल पर भेजा जाता है और स्क्रिप्ट cron से चलाई जाती है।
Q30. What is the difference between > , >> , 2>&1 and | ?
> standard output को फ़ाइल में भेजता है और उसे overwrite करता है; >> आख़िर में जोड़ता है। 2> standard error को भेजता है, और 2>&1 standard error को वहीं भेजता है जहाँ standard output जा रहा है, इसलिए cmd > out.log 2>&1 दोनों पकड़ता है। | (pipe) एक command का output अगली command का input बनाता है। /dev/null में लिखी हर चीज़ फेंक दी जाती है।
ट्रबलशूटिंग सिनेरियो
Q31. A server is very slow. How do you find out why?
Load के लिए uptime, हर process का CPU और memory देखने के लिए top या htop, memory और swap के लिए free -h, CPU wait और swapping के लिए vmstat 1, disk latency के लिए iostat -x 1, और नेटवर्क के लिए ss या iftop देखिए। dmesg और journalctl में OOM kill या hardware error दिखते हैं। पता लगाइए कि कौन सा resource भरा है, फिर कौन सा process उसे इस्तेमाल कर रहा है।
Q32. A website on the server is not loading. What do you check?
परत दर परत जाँचिए: सर्विस चल रही है (systemctl status nginx) और port पर सुन रही है (ss -tlpn)? सर्वर पर curl localhost काम करता है? DNS सही IP पर resolve होता है? Firewall और क्लाउड security group ports 80 और 443 allow करते हैं? TLS certificate valid है? फिर असली error के लिए web server और application के error logs पढ़िए।
Q33. You get "Permission denied" running a script. What could be wrong?
फ़ाइल पर execute परमिशन न हो (chmod +x script.sh, या bash script.sh से चलाइए); user के पास फ़ाइल या किसी parent directory पर परमिशन न हो; file system noexec से mount हो (/tmp में आम); SELinux या AppArmor रोक रहा हो; या स्क्रिप्ट में Windows वाली line endings हों, जिससे "bad interpreter" error आता है और dos2unix से ठीक होता है।
Q34. How do you find which process is using a port?
ss -tlpn | grep :8080 या lsof -i :8080 बताता है कि port 8080 पर कौन सा process और PID सुन रहा है (दूसरे users के processes देखने के लिए sudo से चलाइए)। फिर तय कीजिए कि उस process को रोकना है या अपने एप्लिकेशन को दूसरा port देना है।
Linux प्रैक्टिकल तरीके से सीखें
उत्तर याद होना आधा काम है; इंटरव्यू में यह भी पूछा जाता है कि आपने खुद क्या बनाया है। Technical Guftgu की Linux ट्रेनिंग हिंदी में लाइव क्लास, लैब और प्रोजेक्ट के साथ होती है, और रिज़्यूमे व मॉक इंटरव्यू में मदद मिलती है। हम नौकरी या प्लेसमेंट की गारंटी नहीं देते।