Linux Interview Questions and Answers
1. What is Linux?Linux is an open-source, Unix-like operating system based on the
Linux kernel. It's known for its stability, security, and flexibility, and it's
widely used in servers, cloud environments, and embedded systems.
2. What is the difference between Linux and Unix?Unix is a proprietary OS
originally developed in the 1970s, while Linux is a free, open-source alternative.
Linux is more portable and widely used today, especially in cloud and server
environments.
3. What are inodes in Linux?An inode is a data structure used to store information
about a file, such as its size, owner, permissions, and location on disk—but not
its name.
4. What is the difference between a process and a thread?A process is an
independent program in execution with its own memory space. A thread is a
lightweight subprocess that shares memory with other threads in the same process.
5. How do you check disk usage in Linux?Use df -h to check disk space and du -sh to
check the size of a specific directory.
6. What is the difference between absolute and relative path?An absolute path
starts from the root (/), while a relative path is relative to the current working
directory.
7. What is the use of chmod, chown, and chgrp?
chmod: Changes file permissions
chown: Changes file owner
chgrp: Changes group ownership of a file
8. How do you create, delete, and rename a file or directory?
Create: touch file.txt, mkdir dir_name
Delete: rm file.txt, rmdir dir_name
Rename: mv old_name new_name
9. How do you find a file in Linux?Use find /path -name filename or locate filename
(after running updatedb).
10. How do you check running processes?Use ps aux, top, or htop (if installed).
11. How do you kill a process in Linux?Use kill PID, kill -9 PID for force kill, or
pkill process_name.
12. What is the difference between &, nohup, and screen?
&: Runs a command in the background.
nohup: Keeps command running after logout.
screen: Provides a persistent terminal session.
13. How do you add or delete a user in Linux?
Add: adduser username
Delete: userdel username
14. How do file permissions work in Linux?Permissions are in rwx format: read,
write, execute. They can be set using symbolic or octal format (e.g., chmod 755
file).
15. What’s the difference between soft link and hard link?
Soft link (symlink): A shortcut to a file.
Hard link: A mirror copy that points to the same inode.
16. How do you check network connectivity?Use ping, netstat, ss, ifconfig, or ip a.
17. How to open a specific port in Linux?Use iptables, ufw, or firewalld to allow
traffic on the port. Example: sudo ufw allow 8080.
18. How do you SSH into a remote machine?Use: ssh user@ip-address
19. What’s the difference between bash and sh?bash is an enhanced version of sh
with more features like command history, arrays, and scripting options.
20. What are some basic shell commands you use daily?cd, ls, cp, mv, rm, cat, grep,
echo, pwd, man
21. How do you write a simple bash script?
#!/bin/bash
echo "Hello, World!"
dob : 12-11-2005
pin : 841301
roll no : 2304023
Papa ji ka 8051925289
address : husse chapara bihar saran
Father's name - vishwakarma prasad
Mother- sunita devi
Save as script.sh, then run with chmod +x script.sh and ./script.sh
22. What is a cron job and how do you schedule one?A cron job is used to schedule
tasks. Edit with crontab -e. Example to run a script daily:
0 0 * * * /path/to/script.sh
23. How do you monitor system performance (CPU, RAM)?Use top, htop, vmstat, free -
h, or iostat.
24. Explain the boot process in Linux.
BIOS/UEFI loads and initializes hardware.
Bootloader (GRUB) loads the kernel.
Kernel initializes system and mounts root filesystem.
init or systemd starts services and login prompt.
25. What’s the purpose of system logs and where are they stored?Logs help monitor
system behavior. Most logs are in /var/log/, like /var/log/syslog,
/var/log/auth.log, /var/log/messages.