Sunday, May 3, 2026

Linux Interview Que.

1. What is Linux?

Answer:
Linux is an open-source, Unix-like operating system based on the Linux kernel. It manages hardware resources and provides services for applications.

πŸ”Ή 2. Explain Linux boot process

Answer:

BIOS/UEFI initializes hardware
Bootloader (GRUB) loads kernel
Kernel initializes system
init / systemd starts services
System reaches target (multi-user/graphical)

πŸ”Ή 3. What is the difference between hard link and soft link?

Answer:

Hard link: Points to same inode, survives file deletion
Soft link (symlink): Points to file path, breaks if original file is deleted

πŸ”Ή 4. What is a process?

Answer:
A process is a running instance of a program with its own memory space and PID.

πŸ”Ή 5. How do you check CPU and memory usage?

Answer:

CPU: top, htop, mpstat
Memory: free -m, vmstat

πŸ”Ή 6. Difference between df and du?

Answer:

df: Shows filesystem disk usage
du: Shows directory/file usage

πŸ”Ή 7. What is swap memory?

Answer:
Swap is disk space used as virtual memory when RAM is full.

πŸ”Ή 8. What is /etc/fstab?

Answer:
A configuration file that defines filesystems to mount at boot time.

πŸ”Ή 9. How do you find large files?

Answer:

find / -type f -size +500M
πŸ”Ή 10. What is SSH?

Answer:
SSH (Secure Shell) is a secure protocol for remote login and command execution.

πŸ”Ή 11. How do you secure SSH?

Answer:

Disable root login
Use key-based authentication
Change default port
Use firewall rules
πŸ”Ή 12. What is cron?

Answer:
Cron is a job scheduler to run tasks automatically at scheduled times.

πŸ”Ή 13. What is LVM?

Answer:
LVM (Logical Volume Manager) allows flexible disk management, resizing partitions without downtime.

πŸ”Ή 14. What is RAID?

Answer:
RAID is data storage virtualization combining multiple disks for redundancy/performance.

RAID 0 → performance
RAID 1 → mirroring
RAID 5 → parity
πŸ”Ή 15. How do you check open ports?

Answer:

ss -tuln
πŸ”Ή 16. How do you check running processes?

Answer:

ps -ef
top
πŸ”Ή 17. Server is slow — how do you troubleshoot?

Answer (structured approach):

Check CPU → top
Check memory → free -m
Check disk → df -h, iostat
Check logs → /var/log/messages
Check network → ss, netstat
πŸ”Ή 18. Disk is full — what will you do?

Answer:

Check usage → df -h
Find large files → du -sh *
Clean logs → /var/log
Remove temp files → /tmp
Extend disk (LVM if available)
πŸ”Ή 19. High CPU usage — how to identify?

Answer:

top
ps -eo pid,ppid,cmd,%cpu --sort=-%cpu
πŸ”Ή 20. What is load average?

Answer:
Load average shows number of processes waiting for CPU.

Compare with CPU cores
Load > cores → system overloaded
πŸ”Ή 21. Difference between process and thread?

Answer:

Process: Independent, own memory
Thread: Lightweight, shares memory
πŸ”Ή 22. What are file permissions?

Answer:
Permissions control access:

Read (r), Write (w), Execute (x)
Owner, Group, Others
Example:
chmod 755 file
πŸ”Ή 23. What is a zombie process?

Answer:
A zombie process is a completed process whose entry still exists in process table.

πŸ”Ή 24. How do you monitor logs in real time?

Answer:

tail -f /var/log/syslog
πŸ”Ή 25. What is systemd?

Answer:
Systemd is the init system and service manager in modern Linux.

Friday, May 1, 2026

what happens when Linux runs out of RAM and swap

  1. Page cache reclaim
  2. Swap out inactive pages
  3. OOM killer to terminate largest offender If swap=0 → OOM killer triggers earlier.

What is SELinux and how does it work?

Mandatory access control (MAC) enforcing rules on processes using labels. Policies restrict what a process can do even if it’s root. Modes: enforcingpermissivedisabled.

What is Cow “copy-on-write” in Linux.

When a process forks, parent and child share pages. Memory pages are only duplicated if one modifies them. Saves memory and speeds up process creation.

What is the role of /proc filesystem?

Pseudo-filesystem exposing kernel and process info:

  • /proc/cpuinfo
  • /proc/meminfo
  • /proc/<pid>/status Used for debugging and monitoring.

What is the difference between fork() and exec()?

fork() → creates a copy of the process exec() → replaces process memory with a new program Typically used together to spawn programs.

What is the difference between load average and CPU usage?

  • CPU usage = % CPU is busy
  • Load average = number of processes waiting for CPU or I/O High load average with low CPU = I/O bottleneck

What is a file descriptor?

An integer that refers to an open file, socket, or pipe. Standard ones:

  • 0 → stdin
  • 1 → stdout
  • 2 → stderr

What is cgroups and why is it used?

Control groups limit and control resource usage: CPU, memory, IO, pids, etc. Used by DockerKubernetes, systemd.

What are Linux namespaces?


Namespaces isolate system resources for containers:

  • pid – process IDs
  • net – network interfaces
  • mnt – mounts
  • ipc – message queues
  • uts – hostname
  • user – UID/GID mappings This provides container-level isolation.

How to Troubleshoot CPU,I/O,Memory,Network in Linux.

  • Debug high CPU → toppidstat -ustrace
  • Debug high I/O → iotopiostat
  • Debug memory leak → topsmempmap
  • Debug network → sstcpdumpcurl -v
  • DNS issues → dig/etc/resolv.conf
  • System slow → check: dmesgjournalctl, load average.

Sunday, April 26, 2026

How To set the sticky bit on a folder in Linux/Unix,

You typically use the chmod command.

chmod +

chmod 1777 <folder_name>


Thursday, April 23, 2026

What is SLI SLO SLA ?


- SLI (Service Level Indicator): This is the metric you're measuring. For a login service, it could be the ratio of successful login requests to total valid requests. It tells you how your service is performing right now. - SLO (Service Level Objective): You take that SLI and define a target around it. Something like "login availability should stay above 99.9% over a rolling 28-day window." When you're missing your SLO, it’s a signal to find out what's failing before customers notice. - SLA (Service Level Agreement): This is what you promise your customers in a contract. It's usually set lower than the SLO, say 99.5% monthly availability. If you breach it, you owe service credits.

What is the difference between a Pod, ReplicaSet, and Deployment?


In Kubernetes:

- Pod: The smallest deployable unit. It runs one or more containers that share networking and storage.

- ReplicaSet: Ensures a specified number of identical Pods are running at all times. It automatically creates or deletes Pods to maintain the replica count.

- Deployment: A higher-level object that manages ReplicaSets. It provides declarative updates, rolling deployments, and easy rollbacks.

In short:  
Pod = runs your app  
ReplicaSet = keeps the right number of Pods alive  
Deployment = handles updates and rollouts on top of ReplicaSet

Tuesday, April 7, 2026

Core Linux Kernel Components

1️⃣ Process Management
Handles creation, scheduling, and termination of processes.
Creates processes (fork, exec) 
Schedules CPU time (scheduler) 
Context switching between processes 
πŸ‘‰ Example:
When you run top, multiple processes compete for CPU → kernel decides who runs 
 
2️⃣ Memory Management
Controls how memory (RAM) is used.
Virtual memory (each process gets its own space) 
Paging & swapping 
Memory allocation & deallocation 
πŸ‘‰ Key concept:
Virtual Memory lets processes think they have large continuous memory 
 
3️⃣ File System (VFS Layer)
Manages files and storage devices.
Provides a unified interface via Virtual File System (VFS) 
Supports multiple filesystems: 
o ext4 
o xfs 
o btrfs 
πŸ‘‰ Example:
/home, /etc, /var all handled through VFS abstraction 
 
4️⃣ Device Drivers
Interface between hardware and kernel.
Disk drivers 
Network card drivers 
USB drivers 
πŸ‘‰ Without drivers:
OS cannot talk to hardware 
 
5️⃣ Networking Stack
Handles all networking operations.
TCP/IP protocol implementation 
Packet routing 
Socket interface 
πŸ‘‰ Example:
When you ping or curl, kernel networking stack handles packets 
 
6️⃣ System Call Interface (SCI)
Bridge between user space and kernel space.
Programs request kernel services via system calls 
Examples: 
o read() 
o write() 
o open() 
πŸ‘‰ Think:
System calls = controlled entry points into kernel
 
7️⃣ Security (LSM Framework)
Provides security mechanisms.
SELinux 
AppArmor 
Capabilities 
πŸ‘‰ Example:
Restrict what processes can access 
 
8️⃣ Inter-Process Communication (IPC)
Allows processes to communicate.
Pipes 
Shared memory 
Message queues 
Signals 
 
9️⃣ Resource Management (Cgroups)
Controls resource usage per process/group.
CPU limits 
Memory limits 
I/O limits 
πŸ‘‰ Uses:
Containers (Docker) 
 
πŸ”Ÿ Namespaces (Isolation)
Provides isolation between processes.
PID, NET, MNT, USER, etc. 
πŸ‘‰ Used heavily in containers
 
🧩 How It All Fits Together
User Applications
       ↓
System Calls
       ↓
---------------------
|   Linux Kernel    |
|-------------------|
| Process Mgmt      |
| Memory Mgmt       |
| File System       |
| Networking        |
| Drivers           |
| Security          |
---------------------
       ↓
Hardware
 
⚡ Quick Real-Life Flow
Example: cat file.txt
1. User runs command 
2. System call → open(), read() 
3. Kernel: 
o Checks permissions (security) 
o Uses filesystem to locate file 
o Uses disk driver to read data 
4. Data returned to user 
 
🧠 Key Takeaways
Kernel = brain of the OS 
Everything goes through it: 
o CPU 
o Memory 
o Disk 
o Network 
Features like namespaces and cgroups enable modern containers