Linux is a mandatory skill for backend developers, DevOps engineers, and SRE roles across India. Whether you are interviewing at Wipro, TCS, HCL, IBM, or an Indian product startup, you will face Linux questions in your technical interview — from file permissions and process management to shell scripting and systemd services.
File Permissions and User Management
Linux file permissions control who can read, write, and execute files. Every file has three permission sets: owner (user), group, and others. Each set has three bits: read (r=4), write (w=2), execute (x=1).
Key commands:
- chmod 755 file — sets owner to rwx (7), group to r-x (5), others to r-x (5)
- chmod u+x file — adds execute permission for the file owner
- chmod -R 644 directory/ — recursively sets permissions on all files
- chown user:group file — changes the owner and group of a file
- chown -R www-data:www-data /var/www/ — recursively change ownership
- ls -la — list files with permissions, owner, group, and size
- umask — controls the default permissions for newly created files
User management:
- useradd -m username — create a new user with a home directory
- usermod -aG sudo username — add a user to the sudo group
- passwd username — set or change a user's password
- cat /etc/passwd — list all users on the system
- id username — show the user ID (UID) and group memberships
SUID, SGID, and Sticky Bit:
- SUID (chmod u+s): when set on an executable, it runs with the owner's privileges (e.g., /usr/bin/passwd is SUID root so any user can change their own password)
- SGID (chmod g+s): on a directory, new files inherit the group of the directory
- Sticky bit (chmod +t): on a directory, only the file owner can delete their own files (used on /tmp)
Process Management and System Monitoring
Process management is heavily tested in Linux interviews. Understanding how to inspect, control, and troubleshoot running processes is essential.
Viewing processes:
- ps aux — list all running processes with CPU and memory usage
- ps -ef — full-format listing with parent process IDs (PPID)
- top — real-time process monitor; press 'k' to kill a process, 'r' to renice
- htop — improved top with a colour interface (may need installation)
- pgrep nginx — find the PID of a process by name
- pstree — display processes as a tree showing parent-child relationships
Controlling processes:
- kill PID — send SIGTERM (graceful termination) to a process
- kill -9 PID — send SIGKILL (forceful termination; the process cannot catch or ignore this)
- killall nginx — terminate all processes named nginx
- pkill -f 'python script.py' — kill processes matching a pattern
- nohup command & — run a command that persists after you log out
- bg and fg — send a process to the background or bring it back to the foreground
System resource monitoring:
- free -h — display memory usage in human-readable units
- df -h — disk space usage per filesystem
- du -sh /var/log/ — size of a specific directory
- vmstat 1 5 — CPU, memory, I/O, and process statistics (1-second intervals, 5 samples)
- iostat — CPU and I/O statistics for block devices
- lsof -p PID — list files opened by a specific process
- lsof -i :8080 — find the process listening on port 8080
systemd service management:
- systemctl start nginx — start a service
- systemctl stop nginx — stop a service
- systemctl restart nginx — restart a service
- systemctl status nginx — check the status and recent logs of a service
- systemctl enable nginx — enable a service to start on boot
- journalctl -u nginx -f — follow the live logs for a specific service
Shell Scripting, Networking Commands, and Interview Scenarios
Shell scripting and networking commands are tested for backend, DevOps, and SRE roles. Expect to write or debug a bash script and troubleshoot network connectivity.
Bash scripting essentials:
- Variables: NAME='value'; echo $NAME (no spaces around = in assignment)
- Conditionals: if [ -f /etc/nginx.conf ]; then echo 'exists'; fi
- Loops: for i in $(seq 1 10); do echo $i; done
- Functions: function greet() { echo "Hello, $1"; }; greet World
- Read input: read -p 'Enter name: ' NAME
- Exit codes: every command returns 0 (success) or non-zero (failure); check with $?
- Redirecting output: command > file (overwrite), command >> file (append), command 2>&1 (stderr to stdout)
- Pipes: ps aux | grep nginx | awk '{print $2}' — combine commands
- Cron job syntax: (minute hour day-of-month month day-of-week); 0 2 /scripts/backup.sh runs at 2 AM daily
Networking commands:
- ifconfig / ip addr — view network interfaces and IP addresses
- ip route — view the routing table
- ping 8.8.8.8 — test connectivity to a host
- traceroute google.com — trace the path packets take to a host
- netstat -tlnp — list TCP listening ports with the process name (may need -sudo)
- ss -tlnp — modern replacement for netstat; faster
- curl -I https://example.com — fetch HTTP headers only
- wget https://example.com/file.tar.gz — download a file
- dig google.com — DNS lookup; shows A records, TTL
- nslookup google.com — another DNS query tool
- iptables -L — list firewall rules
Common interview scenario questions:
- 'A process is consuming 100% CPU. How do you find and fix it?' — top to identify the PID, strace -p PID to trace system calls, kill or restart the process
- 'The disk is full. How do you find what is consuming space?' — df -h to see which filesystem, du -sh /* to drill down, find / -size +1G to find large files
- 'How do you check which process is listening on port 80?' — ss -tlnp | grep :80 or lsof -i :80
Frequently asked questions
Explore more