Orientation to Computing — I
Unit 3: Linux Operating System & File System Management
From the terminal to the inode — master the OS that powers 96.3% of the world's servers, learn shell commands that will define your career, and understand how data is organized on disk at the deepest level.
🏢 Industry-Aligned | 📝 15 MCQs (Bloom's Taxonomy) | 🔬 5 Lab Exercises | 💼 Interview & Career Prep
Why This Chapter Changes How You Work With Computers
Here's a number that should make you sit up: 96.3% of the world's top 1 million web servers run Linux. Every time you open Instagram, book an IRCTC ticket, order on Swiggy, or pay via PhonePe — your request hits a Linux server. The cloud infrastructure of AWS, Google Cloud, and Azure? Linux. Android phones? Linux kernel. Every single one of the world's 500 fastest supercomputers? Linux. If you want a career in tech — backend, DevOps, cloud, cybersecurity, data engineering — Linux isn't optional. It's the foundation.
And the file system? It's the invisible architecture that decides where your data lives, how quickly it can be found, and whether it survives a power failure. Understanding inodes, ext4, journaling, and partition tables separates the engineer who uses a computer from the engineer who understands one.
🏢 Industry Snapshot — Who Uses This Knowledge Daily?
Flipkart — During Big Billion Days, Flipkart's 10,000+ servers (all running Linux) handle 1.5 billion API requests per hour. Their SRE team uses top, htop, ps aux, df -h, and tail -f /var/log/nginx/access.log in real-time to monitor server health. One misconfigured permission (chmod 777) on a production config file once exposed database credentials. Linux knowledge isn't "nice to have" — it's a survival skill.
ISRO — The Indian Space Research Organisation uses Linux for ground station computing, satellite data processing, and mission control. The Chandrayaan-3 ground software ran on CentOS/RHEL-based systems. ISRO engineers work in terminals, not GUIs — ssh, scp, and shell scripting are their daily tools.
TCS, Infosys, Wipro — Over 80% of enterprise clients run Linux servers. Every fresh hire at these companies learns Linux commands, file permissions, and shell scripting in their first training month. When a production incident happens at 2 AM, you don't click around a GUI — you SSH into the server and read logs with grep, tail, and awk.
Prerequisite Checklist ✅
- ✅ You understand what an OS does (from Unit 2) — process, memory, file, and device management
- ✅ You know the boot process — BIOS/UEFI → POST → Bootloader → Kernel → Login
- ✅ You've used a GUI-based OS (Windows or macOS) — now you'll learn to do everything from the command line
- ✅ You know absolute vs relative paths (from Unit 2) —
/home/rahul/project.pyvs./project.py - ✅ No prior Linux experience needed — this chapter starts from zero and builds to job-ready
Learning Outcomes — Bloom's Taxonomy
| Bloom's Level | Learning Outcome |
|---|---|
| L1 — Remember | List 10 essential Linux shell commands with their syntax, name 5 Linux distributions and their use cases, and recall the key directories in the Linux file hierarchy (/etc, /var, /home, /bin) |
| L2 — Understand | Explain the difference between a shell and a terminal, describe how Linux file permissions work (rwx, octal notation), and articulate why journaling file systems prevent data corruption |
| L3 — Apply | Use chmod, chown, and chgrp to set appropriate permissions on files, execute piping and redirection to chain commands, and mount/unmount file systems |
| L4 — Analyze | Compare ext4, NTFS, FAT32, and Btrfs file systems for different use cases, and analyze why Linux dominates server environments while Windows dominates desktops |
| L5 — Evaluate | Justify the choice of a specific Linux distribution for a given deployment scenario (web server vs penetration testing vs embedded IoT), and evaluate MBR vs GPT partitioning for modern hardware |
| L6 — Create | Design a complete server setup plan including OS selection, partition scheme, file system choice, and permission strategy for a multi-user development environment |
Concept Explanations — Theory, Earned
Part A — Linux Operating System
3.1 What Is Linux?
📌 Linux — The World's Most Important Operating System
Linux is a free, open-source, UNIX-like operating system kernel created by Linus Torvalds in 1991. Unlike Windows (owned by Microsoft) or macOS (owned by Apple), Linux's source code is publicly available — anyone can read it, modify it, distribute it. What we commonly call "Linux" is actually GNU/Linux — the Linux kernel combined with the GNU project's user-space tools (bash, coreutils, gcc) and a distribution's package manager, desktop environment, and configurations.
🌍 REAL-WORLD ANALOGYThink of Linux as a restaurant recipe that's publicly shared. Windows is like a McDonald's franchise — you buy the meal, but you can't see or modify the recipe. Linux is like an open recipe on GitHub — anyone can cook it, modify the spices (customize the OS), and share their version. That's why there are hundreds of Linux "flavors" (distributions): Ubuntu, Fedora, Arch, Kali — each is a chef's take on the same base recipe.
⚙️ HOW IT WORKSLinux Architecture Stack
┌────────────────────────────────────────────────────────┐
│ USER (You) │
├────────────────────────────────────────────────────────┤
│ APPLICATION LAYER │
│ Firefox │ VS Code │ Python │ Docker │ Node.js │
├────────────────────────────────────────────────────────┤
│ SHELL (bash, zsh, fish) │
│ Interprets your commands → translates to system calls │
├────────────────────────────────────────────────────────┤
│ GNU UTILITIES │
│ ls, cp, mv, grep, awk, sed, chmod, ps, kill │
├────────────────────────────────────────────────────────┤
│ LINUX KERNEL │
│ ┌────────────────────────────────────────────────┐ │
│ │ Process Scheduler │ Memory Manager │ VFS │ │
│ │ Device Drivers │ Network Stack │ Security │ │
│ └────────────────────────────────────────────────┘ │
├────────────────────────────────────────────────────────┤
│ HARDWARE │
│ CPU │ RAM │ SSD/HDD │ GPU │ NIC │ USB │
└────────────────────────────────────────────────────────┘
🏢 INDUSTRY USE
96.3% of the top 1 million web servers run Linux. All 500 of the world's fastest supercomputers run Linux. Every AWS EC2 instance defaults to Amazon Linux (based on RHEL/CentOS). IRCTC runs on Linux servers handling 25 million bookings daily. Jio's telecom infrastructure, AIIMS hospital management systems, every IIT server — all Linux. Google runs over 4 million Linux servers.
⚠️ COMMON MISCONCEPTION"Linux is hard and only for hackers." No. Ubuntu and Linux Mint are as easy as Windows for daily use. Android — the OS on your phone — is Linux. Chrome OS (on Chromebooks) is Linux. Smart TVs, WiFi routers, and ATMs all run Linux. You've been using Linux every day without knowing it.
3.2 Linux Features & Distributions
Core Features of Linux
| Feature | What It Means | Industry Impact |
|---|---|---|
| Open Source | Source code is freely available under GPL license. Anyone can view, modify, and distribute. | No licensing cost — ISRO, Indian Railways, NIC save ₹100s of crores on OS licenses |
| Multitasking | Runs hundreds of processes simultaneously using preemptive scheduling | A single Flipkart server handles 10,000+ concurrent HTTP requests |
| Multi-user | Multiple users can log in and work simultaneously, each with isolated home directories and permissions | IIT lab servers: 500 students share one server via SSH, each in their own /home/student_id/ |
| Portability | Runs on everything: x86 PCs, ARM phones, RISC-V boards, mainframes, embedded IoT, supercomputers | Same kernel on your Raspberry Pi (₹3,000) and AWS's million-dollar servers |
| Security | Strong permission model (rwx), SELinux/AppArmor, no "admin by default," fewer viruses due to market + architecture | Banking servers at SBI and HDFC run Linux for security. Windows has 100× more malware targets. |
| Stability | Servers run for years without rebooting. Kernel updates can be applied live (kpatch/livepatch) | Google's servers have uptimes measured in years, not days |
| CLI Power | Everything can be done from the command line — scripting, automation, remote administration | DevOps/SRE engineers manage 10,000 servers through CLI scripts, not clicking buttons |
Major Linux Distributions
| Distribution | Based On | Use Case | Indian Context |
|---|---|---|---|
| Ubuntu | Debian | Desktop, servers, cloud, beginners | IIT/NIT computer labs, AWS default, most popular for learning |
| Fedora | Independent (Red Hat upstream) | Developers, cutting-edge features | Red Hat developers in Pune/Bangalore use Fedora as daily driver |
| CentOS / Rocky / Alma | RHEL (free rebuild) | Enterprise servers, production | IRCTC, banks, TCS data centres — "free RHEL" |
| Red Hat Enterprise Linux (RHEL) | Fedora (stabilized) | Enterprise production, certified support | Infosys, Wipro enterprise projects require RHEL for SLA compliance |
| Debian | Independent | Stability-focused servers, IoT | ISRO ground stations, NIC government servers |
| Arch Linux | Independent | Advanced users, DIY, minimal | IIT CS students who want to understand Linux inside out ("BTW, I use Arch") |
| Kali Linux | Debian | Penetration testing, ethical hacking, cybersecurity | CERT-In cybersecurity teams, CEH certification labs |
| Amazon Linux | RHEL/Fedora | AWS EC2 optimized | Every Indian startup using AWS EC2 defaults to this |
wsl --install in PowerShell and you have Ubuntu in 60 seconds. Over 70% of Windows developers now use WSL2 for backend development.
3.3 Linux vs Windows — Detailed Comparison
| Parameter | Linux | Windows |
|---|---|---|
| Cost | Free (₹0). Ubuntu, Fedora, Debian — all free forever | ₹10,000–15,000 per license. Volume licensing for enterprises: ₹3,000+/seat/year |
| Source Code | Open source (GPL). You can read every line of the kernel | Proprietary. Closed source. You can't see how Windows works internally |
| Server Market | 96.3% of top 1M servers. Dominant in cloud, web, supercomputing | ~3.7% of web servers. Used for Active Directory, .NET hosting, SharePoint |
| Desktop Market | ~3-4% globally. Growing in India (government mandates, cost savings) | ~72% globally. Standard for offices, schools, gaming |
| Security | Fewer malware targets. Strong permissions. SELinux/AppArmor. No admin by default | Largest malware target (~95% of all malware targets Windows). UAC for admin elevation |
| Customization | 100% customizable — kernel, desktop, bootloader, everything | Limited — can change wallpaper and some settings, but core OS is locked |
| CLI Power | bash/zsh with 1000s of powerful utilities. Entire server management via terminal | PowerShell (powerful but less mature ecosystem). CMD is legacy |
| Package Manager | apt (Debian/Ubuntu), dnf (Fedora), pacman (Arch) — one command installs anything | Microsoft Store, winget (newer), or download .exe from websites |
| Updates | User controls when to update. No forced restarts. Live kernel patching possible | Forced updates. "Your PC will restart in 15 minutes" during presentations 😤 |
| Hardware Support | Excellent for servers. Desktop hardware support improving but some GPU/WiFi drivers lag | Excellent for desktops. Every manufacturer provides Windows drivers first |
| File System | ext4 (default), Btrfs, XFS, ZFS | NTFS (default), ReFS (Server), FAT32 (USB compatibility) |
| Path Separator | Forward slash: /home/rahul/file.txt | Backslash: C:\Users\Rahul\file.txt |
| Case Sensitivity | Case-sensitive: File.txt ≠ file.txt | Case-insensitive: File.txt = file.txt |
3.4 Shell, Terminal & Console — What's the Difference?
📌 Shell — The Command Interpreter
A shell is a program that interprets your text commands and translates them into system calls that the kernel understands. It's the bridge between you (typing ls -la) and the kernel (performing a directory listing). The shell is NOT the black window — that's the terminal.
If the kernel is a restaurant kitchen, the shell is the waiter who takes your order (command), translates it into kitchen language (system calls), and brings back the result (output). The terminal is the dining table where you sit and interact with the waiter. The console is the specific physical restaurant location (hardware terminal).
⚙️ KEY DISTINCTIONS| Term | What It Is | Example |
|---|---|---|
| Terminal (Emulator) | The GUI window that displays text input/output. It's just a container. | GNOME Terminal, iTerm2, Windows Terminal, Alacritty |
| Shell | The program INSIDE the terminal that interprets commands. Different shells have different features. | bash, zsh, fish, sh, dash, PowerShell |
| Console | The physical/system-level terminal. On Linux, Ctrl+Alt+F1 through F6 open virtual consoles (no GUI). | TTY1-TTY6 on Linux, the blue BIOS/UEFI screen |
| Shell | Full Name | Key Features | Status |
|---|---|---|---|
| bash | Bourne Again Shell | Default on most Linux distros. Scripting standard. Tab completion. History. Widely documented. | ✅ Industry standard |
| zsh | Z Shell | Default on macOS since Catalina. Superior auto-completion. Themes (Oh My Zsh). Plugin ecosystem. | ✅ Growing fast |
| fish | Friendly Interactive Shell | Syntax highlighting out of the box. Auto-suggestions. Beginner-friendly. Web-based configuration. | 🟡 Niche but loved |
| sh | Bourne Shell | Original UNIX shell. Minimal. Used for portable scripts (#!/bin/sh). | ⬜ Legacy baseline |
| dash | Debian Almquist Shell | Minimal POSIX shell. Ubuntu uses it for /bin/sh (faster boot scripts). | ⬜ System scripts only |
"Terminal and shell are the same thing." No. You can change your shell without changing your terminal, and vice versa. Running chsh -s /bin/zsh switches your shell to zsh, but you're still using the same GNOME Terminal window. Think: terminal = TV screen, shell = TV channel. Same screen, different channel.
ssh username@server-ip. Every DevOps/SRE/backend engineer uses SSH daily. Flipkart's SRE team manages 10,000+ servers via SSH — they never physically touch the machines. SSH keys (passwordless login) are standard in industry.
3.5 Navigation Commands
ls [options] [path]ls -la /home/rahul/ls -la output: -rw-r--r-- = regular file, owner can read/write, group and others can only read. d prefix = directory. l prefix = symbolic link. The columns are: permissions | links | owner | group | size | date | name. You'll use this 50 times a day.
| Flag | What It Does | Example |
|---|---|---|
ls | Basic listing (names only) | ls |
ls -l | Long format (permissions, owner, size, date) | ls -l |
ls -a | Show hidden files (files starting with .) | ls -a (shows .bashrc, .ssh/) |
ls -la | Long format + hidden files (most common usage) | ls -la /etc/ |
ls -lh | Human-readable sizes (KB, MB, GB instead of bytes) | ls -lh → shows 4.2K instead of 4296 |
ls -lS | Sort by file size (largest first) | ls -lS /var/log/ |
ls -lt | Sort by modification time (newest first) | ls -lt |
ls -R | Recursive — list all subdirectories too | ls -R /home/rahul/projects/ |
cd [path]| Command | Effect | Real-World Use |
|---|---|---|
cd /var/log | Go to /var/log (absolute path) | Navigate to server logs directory |
cd Documents | Go to Documents subdirectory (relative) | Navigate into a project folder |
cd .. | Go up one directory (parent) | Back out of a nested folder |
cd ~ or just cd | Go to your home directory (/home/username) | Quick return to home from anywhere |
cd - | Go to the previous directory (toggle) | Jump between two directories you're working in |
cd / | Go to the root directory | Starting point for absolute navigation |
pwdpwd → /home/rahul/projects/backendrm -rf *clear (or shortcut: Ctrl + L)3.6 File Operations Commands
touch filenametouch index.html style.css app.js — creates 3 empty files at oncecp [options] source destinationcp file.txt backup.txt — copy filecp -r projects/ projects_backup/ — copy entire directory (-r = recursive)cp -i file.txt /tmp/ — interactive: asks before overwriting (-i)cp nginx.conf nginx.conf.bakmv source destinationmv old_name.py new_name.pymv report.pdf ~/Documents/rm [options] filerm temp.log — delete a single filerm -r old_project/ — delete directory recursivelyrm -rf build/ — force delete without confirmationrm -i *.log — interactive: asks before each deletionrm -rf / will delete your ENTIRE system. There is NO recycle bin in Linux CLI. Deleted = gone forever. ALWAYS double-check your pwd before running rm -rf. In 2017, a GitLab engineer accidentally ran rm -rf on a production database directory and deleted 300 GB of user data.rm command permanently deletes files. There's no undo. Professional teams use trash-cli (a safe alternative) or configure alias rm='rm -i' (interactive mode) to prevent accidents. On servers, backups and snapshots (ZFS/Btrfs snapshots) are your safety net.
mkdir project — create one directorymkdir -p src/components/ui — create entire path (-p = parents)rmdir empty_folder — only works if directory is EMPTYmkdir -p is used in CI/CD scripts to create deployment directories that may or may not existViewing File Contents
| Command | Behavior | Best For | Example |
|---|---|---|---|
cat file | Dumps entire file to terminal | Small files (<100 lines) | cat .bashrc |
more file | Page-by-page forward viewing | Medium files (legacy tool) | more /etc/passwd |
less file | Page-by-page with backward scroll, search (/pattern) | Large files, log files | less /var/log/syslog |
head -n 20 file | Shows first N lines | Check file header/format | head -n 5 data.csv |
tail -n 20 file | Shows last N lines | Check latest log entries | tail -n 50 error.log |
tail -f file | Follow: continuously shows new lines as they're added | Real-time log monitoring | tail -f /var/log/nginx/access.log |
tail -f is the #1 debugging tool in production. When something goes wrong on a Flipkart server at 2 AM, the SRE runs tail -f /var/log/nginx/error.log to watch errors appear in real-time. Combined with grep: tail -f access.log | grep "500" shows only HTTP 500 errors as they happen.
Text Editors in Terminal
| Editor | Learning Curve | When to Use |
|---|---|---|
nano | Easy — controls shown at bottom (Ctrl+O save, Ctrl+X exit) | Quick edits, beginners, editing config files on servers |
vi / vim | Steep — modal editor (insert mode, command mode, visual mode) | Available on EVERY Linux system. Industry standard. Required for sysadmin work |
Esc, then type :wq (write and quit) or :q! (quit without saving). Learning vim is a career investment — it's on every server, even in minimal rescue environments.
3.7 File Permissions & Ownership
📌 Permissions — Linux's Security Foundation
Every file and directory in Linux has three types of permissions for three categories of users. Permissions determine who can read, write, or execute a file. This is Linux's core security model — it's why Linux servers can safely host millions of users without them accessing each other's data.
⚙️ HOW IT WORKSPermission Structure
-rwxr-xr-- 1 rahul developers 4096 Jun 15 project.py
│└┬┘└┬┘└┬┘ └──┬── └────┬─────
│ │ │ │ │ │
│ │ │ │ │ └── Group (developers)
│ │ │ │ └─────────── Owner (rahul)
│ │ │ └── Others permissions: r-- (read only)
│ │ └───── Group permissions: r-x (read + execute)
│ └───────── Owner permissions: rwx (read + write + execute)
└──────────── File type: - (file), d (directory), l (link)
Permission Meaning for FILE Meaning for DIRECTORY
────────── ───────────────── ──────────────────────
r (read) Can view contents Can list contents (ls)
w (write) Can modify contents Can create/delete files inside
x (execute) Can run as program Can cd into directory
📌 OCTAL (NUMERIC) NOTATION
| Permission | Binary | Octal | Meaning |
|---|---|---|---|
--- | 000 | 0 | No permissions |
--x | 001 | 1 | Execute only |
-w- | 010 | 2 | Write only |
-wx | 011 | 3 | Write + Execute |
r-- | 100 | 4 | Read only |
r-x | 101 | 5 | Read + Execute |
rw- | 110 | 6 | Read + Write |
rwx | 111 | 7 | Read + Write + Execute (full) |
chmod Examples
# Symbolic notation
chmod u+x script.sh # Add execute permission for owner (u=user)
chmod g-w config.yml # Remove write permission from group
chmod o-rwx secret.key # Remove all permissions from others
chmod a+r readme.md # Add read for all (a=all: user+group+others)
# Octal notation (most common in industry)
chmod 755 deploy.sh # rwxr-xr-x (owner: full, group: read+exec, others: read+exec)
chmod 644 index.html # rw-r--r-- (owner: read+write, group/others: read only)
chmod 600 id_rsa # rw------- (owner only — SSH private key!)
chmod 777 test.sh # rwxrwxrwx ⚠️ NEVER use 777 on production!
chmod -R 755 /var/www/ # Apply recursively to all files in directory
⚙️ chown & chgrp — Change Ownership
Ownership Commands
chown rahul file.txt # Change file owner to rahul
chown rahul:developers file.txt # Change owner AND group
chown -R www-data:www-data /var/www/ # Recursive: all files in web directory
chgrp engineers project/ # Change group only
⚙️ umask — Default Permission Mask
umask
# umask defines which permissions are REMOVED from new files
# Default file permission: 666 (rw-rw-rw-)
# Default dir permission: 777 (rwxrwxrwx)
# umask 022 → new files: 666 - 022 = 644 (rw-r--r--)
# → new dirs: 777 - 022 = 755 (rwxr-xr-x)
umask # Show current umask
umask 027 # Set: files=640, dirs=750 (restrict others completely)
🏢 INDUSTRY USE
SSH key security: Your private key (~/.ssh/id_rsa) MUST be chmod 600. If it's world-readable, SSH refuses to use it — by design. Web servers: Nginx/Apache web files are typically chmod 644 (readable by everyone, writable only by owner) with owner www-data. Flipkart's incident: A misconfigured chmod 777 on a config file exposed database credentials in 2019.
"Just use chmod 777 to fix permission errors." NEVER. 777 means everyone can read, write, and execute — it's a massive security hole. It's the Linux equivalent of leaving your house door open with a sign that says "Take anything." Use the minimum permissions needed: 644 for files, 755 for directories and scripts.
3.8 Process Management Commands
📌 Processes — Every Running Program
A process is a running instance of a program. When you type python app.py, the kernel creates a process with a unique ID (PID), allocates memory, and schedules CPU time. Linux can run thousands of processes simultaneously. Understanding processes is essential for debugging ("Why is my server slow?") and administration ("Kill the stuck process").
ps — shows your current shell's processesps aux — shows ALL processes from ALL users (most common)ps aux | grep nginx — find nginx processesq to quit, k to kill.sudo apt install htophtop → find the process eating 95% CPU → investigate or kill itkill 1234 — sends SIGTERM (signal 15) — "please shut down cleanly"kill -9 1234 — sends SIGKILL (signal 9) — "die immediately, no cleanup"killall firefox — kills ALL processes named "firefox"ps aux | grep node → find PID → kill PID → restartkill -9 doesn't let the process clean up. It may leave temp files, corrupt databases, or break lock files. Always try kill (SIGTERM) first. Wait 5 seconds. Only use kill -9 if the process is truly frozen.Ctrl + Z — suspends (pauses) the current foreground processbg — resumes the suspended process in the backgroundfg — brings a background process back to the foregroundjobs — shows all background/suspended jobs in current shellpython train.py & — the & starts the process directly in background3.9 System Information & Networking Commands
System Information
| Command | Output | Real Use |
|---|---|---|
man ls | Manual page for ls command | RTFM — "Read The Fine Manual." Every command has a manual. Press q to quit. |
uname -a | Kernel version, hostname, architecture | Check if server is 64-bit, kernel version for compatibility |
df -h | Disk space usage (human-readable) | "Server disk full!" → df -h → find which partition is 100% |
du -sh * | Size of each file/folder in current directory | Find which folder is eating all the disk space |
free -h | RAM usage (total, used, free, cached) | "Server is slow" → free -h → check if RAM is exhausted |
uptime | How long the system has been running, load average | Check server stability — 400 days uptime = stable system |
whoami | Current username | Verify you're not accidentally logged in as root |
id | User ID (UID), group ID (GID), all groups | Debug permission issues — "Am I in the docker group?" |
hostname | Machine's network name | Verify which server you're SSH'd into (important with 100+ servers!) |
Networking Commands
| Command | What It Does | Example |
|---|---|---|
ping google.com | Tests network connectivity. Sends ICMP packets and measures round-trip time | ping -c 4 irctc.co.in — send 4 pings, check if IRCTC is reachable |
ifconfig / ip addr | Shows network interfaces and IP addresses | ip addr show eth0 — check server's IP address |
curl URL | Transfers data from/to a URL. Downloads web pages, tests APIs | curl https://api.github.com — test if GitHub API responds |
wget URL | Downloads files from the internet | wget https://example.com/dataset.zip — download a file to current directory |
ifconfig is deprecated on modern Linux distributions. Use ip addr, ip link, and ip route instead (from the iproute2 package). However, ifconfig still appears in interviews and older documentation, so know both.
3.10 Piping & Redirection — The Power of Composition
📌 The Unix Philosophy: "Do One Thing Well"
Linux commands are designed to be small, focused tools that do one thing well. The magic happens when you pipe (|) the output of one command as the input to another, creating powerful command chains. This is the Unix philosophy in action — and it's why experienced engineers can do in one line what takes 50 lines of code.
Think of an assembly line in a Maruti Suzuki factory. Station 1 builds the chassis. Station 2 adds the engine. Station 3 paints. Each station does ONE thing well, and the output of one flows into the next. The pipe (|) is the conveyor belt connecting stations.
| Operator | Name | What It Does | Example |
|---|---|---|---|
| | Pipe | Sends output of command1 as input to command2 | ps aux | grep python |
> | Redirect (overwrite) | Sends output to a file (creates or overwrites) | ls -la > filelist.txt |
>> | Redirect (append) | Appends output to end of file | echo "Done" >> log.txt |
< | Input redirect | Reads input from a file instead of keyboard | sort < names.txt |
2>&1 | Merge stderr to stdout | Combines error output with normal output | python app.py > all.log 2>&1 |
2> | Redirect errors only | Sends only error messages to a file | find / -name "*.conf" 2> /dev/null |
Piping in Action
# Find the 10 largest files in /var/log
du -ah /var/log | sort -rh | head -10
# Count how many Python processes are running
ps aux | grep python | wc -l
# Find all unique IP addresses in nginx access log
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
# Find all .py files containing "import flask"
grep -r "import flask" /home/rahul/projects/ | grep ".py:"
# Monitor real-time HTTP 500 errors
tail -f /var/log/nginx/access.log | grep " 500 "
# Save process list to file, including errors
ps aux > processes.txt 2>&1
🏢 INDUSTRY USE
At Flipkart during Big Billion Days: SREs chain commands to find which API endpoints are failing: tail -f access.log | grep "500" | awk '{print $7}' | sort | uniq -c | sort -rn. This one-liner shows the top failing URLs in real-time. Writing this as a Python script would take 20+ lines and be slower.
3.11 Virtual Machines & Hypervisors
📌 Virtual Machines — Running OS Inside an OS
A Virtual Machine (VM) is a software emulation of a complete computer. A hypervisor is the software that creates and manages VMs by allocating physical hardware resources (CPU, RAM, disk) to each VM. Each VM thinks it has its own dedicated hardware, but it's actually sharing the host machine's resources.
🌍 REAL-WORLD ANALOGYA VM is like a PG/hostel room inside a building. The building (physical server) has 10 rooms (VMs). Each room has its own lock (isolation), its own furniture arrangement (OS), and its own residents (applications). The building owner (hypervisor) decides how much electricity (CPU) and water (RAM) each room gets.
⚙️ HYPERVISOR TYPES| Type | Name | How It Works | Examples | Industry Use |
|---|---|---|---|---|
| Type 1 (Bare-Metal) | Runs directly on hardware — no host OS needed | Hypervisor IS the OS. Maximum performance, minimal overhead | VMware ESXi, KVM, Microsoft Hyper-V, Xen | AWS EC2 (KVM-based Nitro), Azure (Hyper-V), every data centre |
| Type 2 (Hosted) | Runs as a program on top of a host OS | Installed like any app. Easier to set up but more overhead | VirtualBox, VMware Workstation, Parallels | Developers running Linux on Windows laptop, testing environments |
Hypervisor Architecture
TYPE 1 (Bare-Metal) TYPE 2 (Hosted)
┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐ ┌───────┐
│ VM 1 │ │ VM 2 │ │ VM 3 │ │ VM 1 │ │ VM 2 │
│Ubuntu │ │Windows│ │CentOS │ │Ubuntu │ │Kali │
├───────┤ ├───────┤ ├───────┤ ├───────┴─┴───────┤
├───────────────────────────┤ │ VirtualBox/VMware│
│ TYPE 1 HYPERVISOR │ ├───────────────────┤
│ (ESXi / KVM / Xen) │ │ HOST OS │
├───────────────────────────┤ │ (Windows 11) │
│ PHYSICAL HARDWARE │ ├───────────────────┤
└───────────────────────────┘ │ PHYSICAL HARDWARE │
└───────────────────┘
🏢 INDUSTRY USE
AWS EC2 — Every EC2 instance is a VM running on AWS's Nitro hypervisor (KVM-based). When you launch an EC2 instance, AWS carves out a VM on one of their physical servers. IIT/NIT labs — one powerful server runs 50 VMs (one per student) instead of maintaining 50 physical PCs. TCS/Infosys development — developers test on different OS versions using VMs without needing multiple laptops.
⚠️ COMMON MISCONCEPTION"VMs and containers (Docker) are the same." No. VMs virtualize the entire hardware — each VM has its own full OS kernel (heavy, GBs of overhead). Containers share the host OS kernel and only isolate the application layer (lightweight, MBs of overhead). VMs take minutes to boot; containers start in seconds. Docker uses Linux namespaces and cgroups — not a hypervisor.
Part B — File System Management
3.12 File System Basics — Inodes & Directory Entries
📌 Inode — The File's Identity Card
An inode (index node) is a data structure that stores all metadata about a file EXCEPT its name and contents. Every file on a Linux system has exactly one inode. The inode contains: file size, owner (UID), group (GID), permissions, timestamps (created, modified, accessed), number of hard links, and pointers to the actual data blocks on disk.
🌍 REAL-WORLD ANALOGYAn inode is like a library catalog card. The card (inode) tells you the book's author (owner), size (pages), location on the shelf (data block pointers), and borrowing rules (permissions). The card itself doesn't contain the book's text (data) or the title displayed on the spine (filename). The directory is like the shelf label that maps "Harry Potter" (filename) → catalog card #4567 (inode number).
⚙️ HOW IT WORKSInode Structure
Directory Entry Inode #4567 Data Blocks
┌───────────────┐ ┌──────────────────┐ ┌────────────┐
│ "project.py" │──────────────│ Inode #4567 │ │ Block 1001 │
│ inode: 4567 │ maps to → │ Size: 2048 bytes │ points → │ import os │
└───────────────┘ │ Owner: rahul │ │ def main():│
│ Group: devs │ ├────────────┤
│ Perms: rw-r--r-- │ │ Block 1002 │
│ Links: 1 │ │ print() │
│ Created: Jun 10 │ │ return 0 │
│ Modified: Jun 15 │ └────────────┘
│ Blocks: 1001,1002│
└──────────────────┘
View inode information
ls -i project.py # Show inode number
4567 project.py
stat project.py # Show all inode metadata
File: project.py
Size: 2048 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 4567 Links: 1
Access: (0644/-rw-r--r--) Uid: (1000/rahul) Gid: (1000/devs)
Access: 2025-06-15 10:30:00
Modify: 2025-06-15 10:28:00
Change: 2025-06-15 10:28:00
🏢 INDUSTRY USE
"Disk is full but df shows space available" — This classic problem happens when you run out of inodes (too many small files) even though data blocks are available. df -i shows inode usage. Flipkart's logging system once filled inodes by creating millions of tiny log files — the fix was log rotation and inode monitoring.
"The filename is stored inside the file." No. The filename is stored in the directory entry, not in the inode or the data blocks. That's why you can have two different filenames pointing to the same inode (hard links). Renaming a file (mv old.txt new.txt) only changes the directory entry — the inode and data are untouched, which is why renaming is instant regardless of file size.
3.13 File System Types — From FAT to ext4
Historical & Current File Systems
| File System | Year | Max File Size | Max Volume | Journaling | Use Case |
|---|---|---|---|---|---|
| FAT12 | 1977 | 32 MB | 32 MB | ❌ | Floppy disks (historical) |
| FAT16 | 1984 | 2 GB | 4 GB | ❌ | MS-DOS, early Windows (historical) |
| FAT32 | 1996 | 4 GB | 2 TB | ❌ | USB drives, SD cards, cross-OS compatibility |
| NTFS | 1993 | 16 EB | 256 TB | ✅ | Windows default. Permissions, encryption, compression |
| HFS+ | 1998 | 8 EB | 8 EB | ✅ | macOS (legacy, replaced by APFS) |
| APFS | 2017 | 8 EB | 8 EB | ✅ (CoW) | macOS/iOS current default |
| ext2 | 1993 | 2 TB | 32 TB | ❌ | Early Linux (no journaling — USB boot drives) |
| ext3 | 2001 | 2 TB | 32 TB | ✅ | ext2 + journaling (legacy Linux servers) |
| ext4 | 2008 | 16 TB | 1 EB | ✅ | Default Linux FS. Reliable, proven, fast. Ubuntu/Fedora default |
| XFS | 1994 | 8 EB | 8 EB | ✅ | Large file handling. Default on RHEL/CentOS. Great for databases |
| Btrfs | 2009 | 16 EB | 16 EB | ✅ (CoW) | Snapshots, compression, RAID. Default on Fedora. "Butter FS" |
| ZFS | 2005 | 16 EB | 256 ZB | ✅ (CoW) | Enterprise: checksums, RAID-Z, snapshots, dedup. Oracle/FreeBSD |
| UDF | 1995 | 16 EB | 2 TB | ❌ | Optical media (DVDs, Blu-ray) |
| GPT | 2000s | Not a file system — it's a partition table format (replaces MBR). Supports 128+ partitions, drives > 2 TB | |||
3.14 Mounting, Unmounting & Disk Partitioning
📌 Mounting — Attaching Storage to the Directory Tree
Mounting is the process of making a file system (on a disk, partition, USB drive, or network share) accessible at a specific directory in the Linux file tree. Unlike Windows (which assigns drive letters: C:, D:, E:), Linux attaches all storage devices into a single unified directory tree under /.
Mounting is like plugging a USB drive into a specific USB port on a hub. The hub is the directory tree, and each port is a mount point. When you mount a drive to /mnt/backup, all files on that drive appear inside /mnt/backup/. Unmounting is safely "ejecting" the drive.
Mount / Unmount
# Mount a USB drive (device /dev/sdb1) to /mnt/usb/
sudo mount /dev/sdb1 /mnt/usb/
# Mount with specific file system type
sudo mount -t ntfs /dev/sdb1 /mnt/windows_drive/
# Unmount safely (ensures all writes are flushed to disk)
sudo umount /mnt/usb/
# View all currently mounted filesystems
mount | grep "^/dev"
df -hT # Shows filesystem type (-T) and usage
# Permanent mount (survives reboot) — edit /etc/fstab
# /dev/sda2 /home ext4 defaults 0 2
📌 DISK PARTITIONING
| Concept | Description |
|---|---|
| Primary Partition | A bootable partition. MBR allows max 4 primary partitions per disk |
| Extended Partition | A container that holds logical partitions. Workaround for MBR's 4-partition limit |
| Logical Partition | Partitions inside an extended partition. Can have many. |
| Feature | MBR (Master Boot Record) | GPT (GUID Partition Table) |
|---|---|---|
| Year | 1983 | 2000s (part of UEFI standard) |
| Max Disk Size | 2 TB | 9.4 ZB (essentially unlimited) |
| Max Partitions | 4 primary (or 3 primary + 1 extended with logical) | 128 partitions (no extended/logical needed) |
| Redundancy | Single copy of partition table — one corruption = all data lost | Stores backup partition table at end of disk |
| Boot Mode | BIOS (legacy) | UEFI (modern) |
| Status | Legacy — avoid for new setups | Standard for all modern systems |
IRCTC server setup: A typical production server has: / (root, 50 GB, ext4), /home (100 GB, ext4), /var (200 GB, XFS — for logs and databases), /boot (1 GB, ext4), swap (16 GB). Separating partitions means if /var/log fills up, it doesn't crash the root filesystem. GPT with UEFI is mandatory for disks > 2 TB — which is every modern server.
3.15 Journaling & File System Comparison
📌 Journaling — Insurance Against Power Failures
A journaling file system maintains a special log (journal) of changes that are about to be made BEFORE actually writing them to disk. If a power failure or crash interrupts a write operation, the file system can replay or discard the incomplete operation from the journal during the next boot — preventing data corruption.
🌍 REAL-WORLD ANALOGYJournaling is like a bank transaction log. Before transferring ₹10,000 from Account A to Account B, the bank writes in the log: "Step 1: Debit A ₹10,000. Step 2: Credit B ₹10,000." If the system crashes after Step 1 but before Step 2, the bank reads the log on restart and either completes the transfer or rolls back Step 1. Without a journal, Account A would lose ₹10,000 and Account B would never receive it.
⚙️ HOW IT WORKSJournaling Process
WITHOUT JOURNALING (ext2, FAT32):
1. Start writing data to disk
2. ⚡ POWER FAILURE mid-write!
3. Reboot → file system is inconsistent → run fsck (slow, may lose data)
4. Full disk scan: 30 minutes for 1 TB drive 😱
WITH JOURNALING (ext3, ext4, NTFS, XFS):
1. Write intent to JOURNAL: "About to modify inode 4567, blocks 1001-1002"
2. Perform actual disk write
3. Mark journal entry as COMPLETE
4. ⚡ POWER FAILURE at step 2?
5. Reboot → read journal → replay or discard incomplete operations
6. Recovery time: 2-5 SECONDS regardless of disk size ✅
📌 JOURNALING MODES (ext4)
| Mode | What's Journaled | Speed | Safety |
|---|---|---|---|
| journal | Both metadata AND data are journaled | Slowest | Safest — no data loss possible |
| ordered (default) | Only metadata journaled, but data is written BEFORE metadata | Medium | Good — data won't reference garbage blocks |
| writeback | Only metadata journaled, data may be written in any order | Fastest | Risky — file may contain old/garbage data after crash |
Why this matters: Imagine IRCTC's database is writing a ticket booking when power fails. Without journaling, the ticket could be half-written — money debited but ticket not confirmed. With journaling (ext4 ordered mode), either the full operation completes or it's completely rolled back. Every production database server uses a journaling file system. No exceptions.
📊 File System Comparison — FAT32 vs NTFS vs ext4 vs Btrfs
| Feature | FAT32 | NTFS | ext4 | Btrfs |
|---|---|---|---|---|
| Max File Size | 4 GB | 16 EB | 16 TB | 16 EB |
| Max Volume | 2 TB | 256 TB | 1 EB | 16 EB |
| Journaling | ❌ No | ✅ Yes | ✅ Yes | ✅ CoW |
| Permissions | ❌ No (anyone can access any file) | ✅ ACLs | ✅ POSIX | ✅ POSIX |
| Snapshots | ❌ | ❌ (VSS is different) | ❌ | ✅ Native |
| Compression | ❌ | ✅ | ❌ | ✅ Transparent |
| Checksums | ❌ | ❌ | ❌ (metadata only) | ✅ Data + metadata |
| Cross-OS | ✅ Win, Mac, Linux | ✅ Win native, Linux read/write via ntfs-3g | ❌ Linux only (Windows needs ext2fsd) | ❌ Linux only |
| Best For | USB drives, SD cards, cross-platform sharing | Windows system drive, external HDDs for Windows | Linux system/data drives (reliable, proven) | Linux with snapshots needed (Fedora default) |
| Limitation | 4 GB file limit! Can't store a 5 GB movie | Not native on Linux/Mac | No snapshots, no checksums | Still maturing; data loss reported in edge cases |
Industry Problems — Case Studies
Case Study 1: IRCTC's Tatkal Booking — Linux Under Extreme Load
The Problem: IRCTC handles 25 million booking requests daily, with massive spikes during Tatkal window (10:00 AM for AC, 11:00 AM for Sleeper). During peak, the system processes 15,000+ transactions per second. In 2014, the system crashed during peak hours, stranding millions of users.
The Linux Solution:
- OS: Migrated from a proprietary Unix system to Red Hat Enterprise Linux (RHEL) on x86 servers
- Monitoring: SREs use
htop,vmstat,iostatto monitor CPU/memory/disk in real-time - Logs:
tail -f /var/log/httpd/access.log | grep "500"catches server errors live - File System: XFS on data partitions (handles large database files efficiently)
- Disk Layout: Separate partitions:
/(root),/var(logs),/data(database) — so log growth never crashes the OS - Permissions: Database files are
chmod 600(owner-only) to prevent unauthorized access
Result: After migration, IRCTC handles 1.5 lakh concurrent users with 99.9% uptime. Linux's stability means servers run for 200+ days without rebooting.
Your Takeaway: Knowing top, df -h, tail -f, and partition management isn't academic — it's how you keep India's railway booking system alive.
Case Study 2: Flipkart Big Billion Days — File Permissions Gone Wrong
The Problem: During a deployment before Big Billion Days 2019, a junior developer ran chmod 777 /etc/app/config.yml on a production server to "fix" a permission error quickly. This made the database credentials in the config file readable by every user on the system.
The Chain Reaction:
- An automated security scanner detected the world-readable config file within 4 minutes
- The incident was escalated as a P1 (highest priority) security alert
- All database credentials had to be rotated (changed) immediately
- 3 hours of deployment delay during the most critical sales event of the year
The Fix (What Should Have Been Done):
Correct Permission Setup
# Config files should be readable only by the application user
chmod 640 /etc/app/config.yml # Owner: rw, Group: r, Others: none
chown app-user:app-group /etc/app/config.yml
# NEVER use 777 on production
# If "permission denied" → find the RIGHT user/group, don't open to everyone
Your Takeaway: Understanding chmod, chown, and the principle of least privilege isn't optional — it's what separates a junior developer from someone trusted with production access.
Case Study 3: AIIMS Ransomware Attack 2022 — File System Recovery
The Problem: In November 2022, AIIMS Delhi's server infrastructure was hit by a ransomware attack that encrypted patient records, appointment data, and hospital management systems. Over 40 million patient records were affected. The hospital had to switch to manual (paper) operations for 2 weeks.
The File System & Linux Connection:
- Root cause: Attackers exploited a Windows server with outdated patches. The primary attack vector was the Windows-based hospital information system
- Recovery: Linux-based backup servers (with ZFS snapshots) were used to restore critical data. ZFS's immutable snapshots couldn't be encrypted by the ransomware
- Lesson: Servers running Linux with proper SELinux policies and ZFS snapshots were unaffected
- Post-incident: CERT-In recommended migrating critical healthcare systems to Linux with mandatory SELinux, encrypted partitions, and automated ZFS snapshot backups
Technical Details:
ZFS Snapshot for Backup
# Create a snapshot (instant, zero-cost copy)
sudo zfs snapshot data/patients@2025-06-15
# List all snapshots
zfs list -t snapshot
# Rollback to snapshot (restore all data to that point in time)
sudo zfs rollback data/patients@2025-06-15
# Snapshots are read-only — ransomware CANNOT encrypt them
Your Takeaway: File system choice has real-world consequences. ZFS/Btrfs snapshots are not just features — they're a cybersecurity defense layer. Understanding journaling, CoW, and snapshots can literally save an organization.
Lab Exercises — Hands-On Practice
Exercise 1: Linux Navigation & File Operations
Objective: Master basic navigation and file manipulation commands.
Environment: Ubuntu terminal (native, WSL2, or VirtualBox VM)
Tasks:
Lab 1 — Step by Step
# Step 1: Verify your location and identity
whoami
pwd
hostname
# Step 2: Create a project directory structure
mkdir -p ~/lab1/src/components ~/lab1/public/images ~/lab1/tests
# Step 3: Navigate and verify
cd ~/lab1
ls -R # Verify the tree structure
tree # If installed: sudo apt install tree
# Step 4: Create files
touch src/app.py src/utils.py tests/test_app.py public/index.html
echo "print('Hello from Linux!')" > src/app.py
echo "<h1>Lab 1</h1>" > public/index.html
# Step 5: View, copy, move, rename
cat src/app.py
cp src/app.py src/app_backup.py
mv src/utils.py src/helpers.py
ls -la src/
# Step 6: Check sizes
du -sh ~/lab1/
wc -l src/app.py # Count lines
# Step 7: Clean up (carefully!)
rm src/app_backup.py
ls src/ # Verify it's gone
Expected Output: A project structure with files created, copied, moved, and listed. Screenshot showing tree output.
Extension: Use find ~/lab1 -name "*.py" to find all Python files. Pipe to wc -l to count them.
Exercise 2: File Permissions & Ownership
Objective: Understand and manipulate Linux file permissions using both symbolic and octal notation.
Tasks:
Lab 2 — Permissions
# Step 1: Create test files
mkdir ~/lab2 && cd ~/lab2
touch public.txt private.txt script.sh config.yml
# Step 2: View default permissions
ls -la
umask # What's the default mask?
stat public.txt # Detailed permission info
# Step 3: Set permissions (symbolic)
chmod u+x script.sh # Make script executable by owner
chmod go-rw private.txt # Remove group & others read/write
chmod a+r public.txt # Everyone can read
# Step 4: Set permissions (octal) — PRACTICE THIS!
chmod 755 script.sh # rwxr-xr-x
chmod 600 private.txt # rw------- (owner only)
chmod 644 config.yml # rw-r--r--
# Step 5: Verify each change
ls -la
# Step 6: Test execution permission
echo '#!/bin/bash' > script.sh
echo 'echo "Hello from script!"' >> script.sh
./script.sh # Should work (755)
chmod 644 script.sh
./script.sh # Should fail: Permission denied!
Record: Fill in this table with the ls -la output after each chmod:
| File | Octal | Symbolic | Who Can Read | Who Can Write | Who Can Execute |
|---|---|---|---|---|---|
script.sh | 755 | ? | ? | ? | ? |
private.txt | 600 | ? | ? | ? | ? |
config.yml | 644 | ? | ? | ? | ? |
Exercise 3: Process Management & System Monitoring
Objective: Monitor processes, manage background jobs, and use piping to analyze system state.
Tasks:
Lab 3 — Processes
# Step 1: System overview
uname -a # Kernel version and architecture
uptime # System uptime and load average
free -h # RAM usage
df -h # Disk usage
# Step 2: View processes
ps aux # All processes
ps aux | head -5 # First 5 lines
ps aux | wc -l # Total process count
# Step 3: Start a background process
sleep 300 & # Start a 5-minute sleep in background
jobs # See background jobs
ps aux | grep sleep
# Step 4: Kill the process
kill %1 # Kill job #1 (graceful)
jobs # Verify it's terminated
# Step 5: Piping challenge — find top 5 memory-consuming processes
ps aux --sort=-%mem | head -6
# Step 6: Run htop (install if needed)
sudo apt install htop -y
htop # Interactive process viewer (press q to quit)
# Step 7: Save system report to file
echo "=== System Report ===" > ~/lab3_report.txt
date >> ~/lab3_report.txt
uname -a >> ~/lab3_report.txt
free -h >> ~/lab3_report.txt
df -h >> ~/lab3_report.txt
cat ~/lab3_report.txt
Expected Output: A complete system report file and screenshots of htop showing process management.
Exercise 4: File System Analysis & Disk Management
Objective: Analyze file systems, examine inodes, and understand mounting.
Tasks:
Lab 4 — File Systems
# Step 1: Check current file system info
df -hT # Show filesystem TYPE and usage
mount | grep "^/dev" # Show mounted devices
# Step 2: Examine inodes
df -i # Inode usage per filesystem
ls -i ~/ # Show inode numbers of files
stat ~/.bashrc # Detailed inode info for a file
# Step 3: Create and examine hard links vs soft links
mkdir ~/lab4 && cd ~/lab4
echo "Original content" > original.txt
ln original.txt hardlink.txt # Hard link (same inode)
ln -s original.txt softlink.txt # Symbolic link (different inode)
ls -li # Compare inode numbers!
# Step 4: Test link behavior
echo "New content" >> original.txt
cat hardlink.txt # Shows new content (same inode!)
cat softlink.txt # Shows new content (follows symlink)
rm original.txt
cat hardlink.txt # STILL works (data exists as long as any hardlink exists)
cat softlink.txt # BROKEN! "No such file" (dangling symlink)
# Step 5: Disk usage analysis
du -ah /var/log 2>/dev/null | sort -rh | head -10
Report: Create a table showing inode numbers for original, hardlink, and softlink. Explain why deleting the original file breaks the softlink but not the hardlink.
Exercise 5: Server Setup Simulation — Complete Linux Deployment Plan
Objective: Design a complete Linux server deployment plan for a real-world scenario.
Scenario: You're the system administrator at a Pune-based startup launching an e-commerce platform (like a mini-Meesho). You need to set up a production web server. Design the complete plan:
| Decision | Your Choice | Justification |
|---|---|---|
| Linux Distribution | ? | Why this distro? Consider stability, support, cost |
| Partition Scheme | ? | What partitions? What sizes? Why separate /var? |
| File System | ? | ext4 or XFS or Btrfs? Why? |
| Partition Table | MBR or GPT? | Why? |
| User Setup | ? | What users/groups? What permissions for web files? |
| Web Server Files | ? | Where? (/var/www/?) What owner/permissions? |
| Backup Strategy | ? | ZFS snapshots? rsync? How often? |
| Monitoring | ? | What commands would you set up for monitoring? |
Deliverable: A 2-page deployment document with your choices and justifications. Include the exact chmod, chown, and partition commands you would run.
Extension: Add a disaster recovery plan: "What do you do when df -h shows /var is 100% full at 3 AM?" List the exact commands you'd run, in order.
MCQ Assessment Bank — 15 Questions
Hover over any question to reveal the answer and full explanation.
What percentage of the world's top 1 million web servers run Linux?
- 45.2%
- 72.8%
- 96.3%
- 100%
🏢 Industry: This is a fundamental fact every CS student should know. It appears in Infosys InfyTQ and TCS NQT aptitude sections.
Which command displays the absolute path of the current working directory in Linux?
cdlspwdwhoami
pwd — pwd stands for "Print Working Directory." It outputs the full absolute path, e.g., /home/rahul/projects/backend. cd changes directory, ls lists contents, whoami shows username. pwd is often the first command you run on a new server to orient yourself — "Where am I?"🏢 Industry: This is a CompTIA Linux+ exam question and appears in every Linux fundamentals assessment.
In the Linux permission string -rwxr-x---, what is the octal representation?
- 755
- 750
- 644
- 700
rwx = 4+2+1 = 7. Group: r-x = 4+0+1 = 5. Others: --- = 0+0+0 = 0. So the octal is 750. The leading - indicates it's a regular file (not directory d or link l). This means: owner has full access, group can read and execute but not modify, others have no access at all.🏢 Industry: Converting between symbolic and octal permissions is a daily skill for sysadmins. This exact pattern (750) is common for scripts shared within a team.
What is the difference between a shell and a terminal in Linux?
- They are the same thing — both refer to the command line interface
- The terminal is the GUI window that displays text; the shell is the program inside it that interprets and executes commands
- The shell is hardware; the terminal is software
- The terminal interprets commands; the shell displays output
chsh -s /bin/zsh) without changing your terminal, and vice versa.🏢 Industry: This distinction matters when configuring development environments. "Which shell are you using?" and "Which terminal are you using?" are different questions with different answers.
Why do journaling file systems (like ext4) recover from crashes faster than non-journaling file systems (like FAT32)?
- Journaling file systems use faster SSDs
- Journaling file systems write all changes to a log (journal) first; on crash recovery, they replay the journal instead of scanning the entire disk — reducing recovery from 30 minutes to seconds
- Journaling file systems don't store data on disk
- Journaling file systems are only used on RAM drives
fsck — a full disk scan that checks every block — which takes 30+ minutes on large disks and may lose data. With journaling, recovery takes 2-5 seconds.🏢 Industry: Every production server uses a journaling FS (ext4, XFS, NTFS). Running a production database on FAT32 would be professional negligence — data loss is inevitable on power failure.
What is an inode in Linux, and what information does it NOT contain?
- An inode stores the file's name and contents
- An inode stores metadata (size, permissions, owner, timestamps, data block pointers) but does NOT store the filename — the filename is stored in the directory entry
- An inode is a type of file system
- An inode only stores the file's creation date
df -i to check inode usage and stat filename to see full inode details.🏢 Industry: Understanding inodes is essential for debugging "No space left on device" errors when
df -h shows available space — it could be an inode exhaustion issue.A developer creates a script deploy.sh and runs it with ./deploy.sh, but gets "Permission denied." The current permissions are -rw-r--r--. What is the correct command to fix this?
chmod 777 deploy.shchmod u+x deploy.shorchmod 755 deploy.shchown root deploy.shmv deploy.sh /bin/
chmod u+x deploy.sh or chmod 755 deploy.sh — The file has rw-r--r-- (644) — no execute permission for anyone. To run a script with ./, the owner needs execute (x) permission. chmod u+x adds execute for the owner only (minimum necessary). chmod 755 sets rwxr-xr-x (owner: full, others: read+execute). Option A (777) works but is a security disaster. Option C changes ownership, not permissions. Option D moves the file, doesn't fix permissions.🏢 Industry: Every CI/CD pipeline script needs execute permission.
chmod +x is one of the most frequently used commands in deployment workflows at companies like Flipkart, Zerodha, and CRED.A sysadmin needs to find all processes consuming more than 10% CPU on a production server and save the output to a file. Which command chain achieves this?
top > cpu_report.txtps aux --sort=-%cpu | awk '$3 > 10' > cpu_report.txtls -la | grep cpucat /proc/cpuinfo > cpu_report.txt
ps aux --sort=-%cpu | awk '$3 > 10' > cpu_report.txt — This chains three operations: (1) ps aux --sort=-%cpu lists all processes sorted by CPU usage descending. (2) awk '$3 > 10' filters only lines where column 3 (CPU %) is greater than 10. (3) > cpu_report.txt redirects output to a file. Option A won't work because top is interactive. Option C searches file names, not processes. Option D shows CPU hardware info, not usage.🏢 Industry: This exact type of command chain is used by SRE teams at TCS, Infosys, and Flipkart for incident response. Being able to construct these pipelines quickly is a key skill in DevOps interviews.
A USB drive formatted as FAT32 cannot store a 5 GB movie file. What is the simplest solution that maintains compatibility with Windows, macOS, and Linux?
- Format the USB as NTFS
- Format the USB as ext4
- Format the USB as exFAT — supports files > 4 GB and is natively supported by all three OS
- Split the file into 4 GB chunks
🏢 Industry: Understanding FAT32's limitations is practical knowledge. USB drives shipped by OEMs (like those with pre-loaded software from HP/Dell) are often FAT32 and hit this limit with large ISO files.
Why does Linux dominate server environments (96.3%) while Windows dominates desktops (72%)? What factors cause this divergence?
- Linux is faster than Windows in all scenarios
- Servers prioritize cost, stability, security, and automation (Linux excels); desktops prioritize hardware compatibility, familiar GUI, and application ecosystem (Windows excels). The requirements are fundamentally different.
- Windows can't run on server hardware
- Linux has better graphics drivers
🏢 Industry: This is a common interview question at TCS, Infosys, and Wipro. The answer demonstrates systems thinking — understanding tradeoffs.
A company discovers that a production server shows "No space left on device" errors, but df -h shows 40% disk space is free. What is the most likely cause?
- The disk is physically damaged
- The file system has run out of inodes — too many small files consumed all inode entries, even though data blocks are available. Verify with
df -i - The server needs more RAM
- The file system doesn't support large files
df -h shows block (data) usage; df -i shows inode usage. Fix: delete unnecessary small files, or recreate the file system with more inodes (mkfs.ext4 -N <inode_count>). Prevention: use tmpfs for session files, implement log rotation, monitor inode usage.🏢 Industry: This is a classic Flipkart/Swiggy SRE interview question. Mail servers (Postfix with Maildir format) and PHP session directories are notorious for inode exhaustion.
A cloud startup needs to choose a file system for their database servers handling financial transactions (like Razorpay). The requirements are: data integrity, crash recovery, and snapshots for backup. Which file system is the best choice?
- FAT32 — simplest and most compatible
- ext4 — default Linux FS, reliable
- ZFS — checksums for data integrity, CoW for crash safety, native snapshots for instant backups, and RAID-Z for redundancy
- NTFS — best for Windows servers
🏢 Industry: Razorpay and similar fintech companies use ZFS on their database/backup servers. Financial regulations (RBI guidelines) require data integrity guarantees that only checksumming file systems provide.
A college student argues: "I should use Kali Linux as my daily operating system because it has the most hacking tools." Evaluate this argument.
- Correct — Kali has all the tools a student needs
- Incorrect — Kali is a specialized penetration testing distribution designed for security professionals. Using it daily is like driving an ambulance for commuting: the tools are unnecessary, the default root user is dangerous, the system isn't optimized for daily use (no office apps, media players, etc.), and running as root means one mistake can destroy the system. Use Ubuntu/Fedora for daily use and Kali in a VM for security labs.
- Partially correct — Kali is fine for beginners
- Incorrect — Kali doesn't work on laptops
🏢 Industry: CERT-In cybersecurity professionals and ethical hackers use Kali in isolated VMs, never as their primary OS. Security is about knowledge, not the tools installed.
You are setting up a multi-user development server for a team of 10 developers at an Indian startup. Design the user/group/permission structure. Which setup is MOST appropriate?
- Give everyone root access for convenience
- Everyone shares a single user account
- Create individual user accounts, a shared group (
developers), project directories owned by root with groupdevelopersand permissions775. Disable root SSH login. Usesudofor admin tasks. Setumask 027for security. - Use Windows Server instead — it has better user management
developers) — team members can collaborate on project files. (3) 775 on project dirs — owner and group have full access, others can read+execute (or 770 for no outside access). (4) Disable root SSH — prevents brute-force attacks on the most powerful account. (5) sudo — individual accountability for admin actions (logged in /var/log/auth.log). (6) umask 027 — new files are group-readable but not world-readable by default. Root access for everyone = zero security. Shared accounts = zero accountability.🏢 Industry: This is the standard setup at TCS, Infosys, and every well-managed Linux environment. SSH key-based authentication (no passwords) is the next layer.
Design a partition scheme for a 2 TB production web server running a Node.js application with a PostgreSQL database. The server will handle 50,000 daily users for an Indian e-commerce startup. Which partition layout is MOST appropriate?
- One big partition for everything — simpler to manage
- C: drive for OS, D: drive for data (Windows approach)
/(50 GB, ext4) |/boot(1 GB, ext4) |/home(100 GB, ext4) |/var(500 GB, XFS) |/var/lib/postgresql(1 TB, XFS) | swap (32 GB) |/backup(remaining, ext4) — with GPT partitioning- No partitions needed — use cloud storage for everything
/var — logs can fill up without crashing the root FS. (2) Separate database partition (/var/lib/postgresql on XFS) — XFS handles large sequential writes (database WAL) better. Separate partition = independent backup, monitoring, and I/O optimization. (3) GPT — 2 TB disk requires GPT (MBR limit = 2 TB). (4) Swap = 1.5× RAM (assuming 16 GB RAM). (5) /backup — dedicated backup space. Single partition = one full /var/log crashes everything. Cloud-only storage adds latency for database operations.🏢 Industry: This layout mirrors what AWS Solutions Architects recommend for e-commerce deployments. Flipkart, Meesho, and Zepto use similar partition schemes for their production databases.
Chapter Summary
Mind Map — All Chapter Concepts
🎯 3 Things Industry Expects You to Know From This Chapter
- Linux Shell Commands —
ls -la,chmod,ps aux,grep,tail -f, piping. On day 1 at any tech company, you'll SSH into a Linux server and need to navigate, read logs, and manage processes. These aren't "extra skills" — they're the baseline. - File Permissions — Understand
rwx, octal notation (644, 755, 600),chown, and whychmod 777is a security disaster. Every production incident involving data exposure traces back to misconfigured permissions. - File System Fundamentals — Know the difference between ext4, NTFS, and FAT32. Understand inodes, journaling, and why partition design matters. When a server runs out of disk space or inodes at 3 AM, this knowledge is your lifeline.
📋 Quick Reference — Essential Linux Commands
NAVIGATION:
pwd → Where am I?
ls -la → List everything (details + hidden)
cd /path/to/dir → Go there
cd ~ or cd → Go home
cd - → Toggle previous directory
FILE OPERATIONS:
touch file.txt → Create empty file
cp -r src/ dest/ → Copy directory recursively
mv old.py new.py → Rename/move
rm -rf directory/ → Delete (⚠️ NO UNDO!)
mkdir -p a/b/c → Create nested directories
cat / less / head / tail → View files
PERMISSIONS:
chmod 755 script.sh → rwxr-xr-x (common for scripts)
chmod 644 file.txt → rw-r--r-- (common for files)
chmod 600 secret.key → rw------- (private files/SSH keys)
chown user:group file → Change owner and group
PROCESSES:
ps aux | grep name → Find process by name
top / htop → Real-time monitoring
kill PID → Graceful stop
kill -9 PID → Force kill (last resort)
SYSTEM INFO:
df -h → Disk space
free -h → RAM usage
uname -a → Kernel info
uptime → System uptime
PIPING & REDIRECTION:
cmd1 | cmd2 → Pipe output to next command
cmd > file → Write to file (overwrite)
cmd >> file → Append to file
cmd 2>&1 → Merge errors with output
FILE SYSTEMS:
FAT32: USB (4 GB limit) | NTFS: Windows | ext4: Linux (default)
Btrfs: snapshots | XFS: databases | ZFS: enterprise
PARTITION TABLE:
MBR: legacy, ≤2 TB, 4 partitions
GPT: modern, unlimited, 128 partitions
🎓 Certification Roadmap
- CompTIA Linux+ (XK0-005) — Covers Linux administration, shell commands, file systems, permissions, and networking. Recognized by TCS, Infosys, and Wipro for Linux admin roles.
- RHCSA (Red Hat Certified System Administrator) — The gold standard for Linux sysadmin certification. Performance-based exam (real tasks on a live RHEL system). Valued at ₹12-18 LPA salary premium in India.
- LPIC-1 (Linux Professional Institute) — Vendor-neutral Linux certification. Covers system architecture, package management, GNU commands, and file systems.
- AWS Solutions Architect Associate — Linux knowledge is prerequisite — 90% of EC2 instances run Linux. Understanding partitioning, permissions, and shell scripting is tested.
📚 What to Explore Next
- YouTube: NetworkChuck (Linux tutorials for beginners), The Linux Experiment, Fireship (short tech explanations)
- Book: "The Linux Command Line" by William Shotts (free PDF available — best beginner Linux book)
- Practice: OverTheWire Bandit (https://overthewire.org/wargames/bandit/) — learn Linux through a cybersecurity game. Free, terminal-based, progressive difficulty.
- Lab: Install Ubuntu on VirtualBox or enable WSL2 on Windows. Practice 30 minutes daily for 2 weeks — you'll be comfortable with the terminal.
Interview & Career Preparation
These questions are asked at TCS NQT, Infosys InfyTQ, Wipro NLTH, Cognizant GenC, AMCAT, GATE CS, and DevOps/SRE interviews.
Q1: What is Linux? Why is it important in the industry?
Model Answer: Linux is a free, open-source, UNIX-like operating system kernel created by Linus Torvalds in 1991. It's important because 96.3% of the world's top web servers run Linux — including AWS, Google Cloud, and Azure. Linux is the backbone of cloud computing, Android phones, supercomputers, and IoT devices. Its advantages: zero licensing cost, exceptional stability (years of uptime), strong security model (permissions, SELinux), powerful CLI for automation, and portability across architectures. Every major Indian tech company (Flipkart, IRCTC, Jio, TCS, Infosys) uses Linux for their server infrastructure.
Q2: What is the difference between a shell, terminal, and console?
Model Answer: A terminal (emulator) is the GUI window that displays text input/output — it's the container (e.g., GNOME Terminal, iTerm2). A shell is the command interpreter program running inside the terminal that parses and executes commands — e.g., bash, zsh, fish. A console is the physical or system-level terminal — on Linux, Ctrl+Alt+F1 opens a virtual console (TTY). Analogy: terminal = TV screen, shell = TV channel, console = the physical TV set. You can change your shell without changing your terminal.
Q3: Explain Linux file permissions. What does chmod 755 mean?
Model Answer: Linux has three permission types (read, write, execute) for three user categories (owner, group, others). In octal notation, each digit represents one category: r=4, w=2, x=1. chmod 755 means: owner gets 7 (rwx = full access), group gets 5 (r-x = read + execute), others get 5 (r-x = read + execute). This is the standard permission for executable scripts and program directories. For regular files, 644 is standard (rw-r--r--). For SSH private keys, 600 is mandatory (rw-------). Never use 777 on production — it gives everyone full access, which is a security vulnerability.
Q4: What is an inode? What information does it store?
Model Answer: An inode (index node) is a data structure that stores metadata about a file: file type, size, owner (UID), group (GID), permissions, timestamps (access, modify, change), number of hard links, and pointers to data blocks on disk. Importantly, the inode does NOT store the filename — that's stored in the directory entry which maps filename → inode number. This is why hard links work (two filenames pointing to the same inode), why renaming is instant (only the directory entry changes), and why you can run out of inodes even with disk space available (df -i to check).
Q5: What is the difference between ext4, NTFS, and FAT32?
Model Answer: ext4 is the default Linux file system — it has journaling for crash recovery, supports files up to 16 TB, and has POSIX permissions. Best for Linux servers and desktops. NTFS is the Windows default — it has journaling, ACL-based permissions, encryption (EFS), and compression. Best for Windows system drives. FAT32 is a legacy file system with no journaling, no permissions, and a 4 GB file size limit — but it's universally compatible across Windows, Mac, and Linux. Best for USB drives and SD cards. For cross-platform drives larger than 4 GB files, use exFAT.
Q6: What is journaling in file systems? Why is it important?
Model Answer: Journaling is a technique where the file system writes changes to a log (journal) before applying them to the actual data. If a crash occurs mid-write, the file system reads the journal on reboot and either completes or rolls back the incomplete operation — recovery takes seconds. Without journaling (FAT32, ext2), the system must scan the entire disk (fsck) — taking 30+ minutes on large drives and potentially losing data. ext4 uses "ordered" journaling by default: metadata is journaled, data is written before metadata. This balance of speed and safety makes it suitable for production servers.
Q7: How would you find and kill a stuck process in Linux?
Model Answer: Step 1: Find the process — ps aux | grep process_name or use htop for an interactive view. This shows the PID (Process ID). Step 2: Try graceful termination — kill PID (sends SIGTERM, signal 15). This lets the process clean up (close files, release resources). Step 3: Wait 5 seconds. If still running — kill -9 PID (sends SIGKILL, signal 9). This immediately terminates with no cleanup. Step 4: Verify — ps aux | grep PID. For killing by name: killall process_name. Always try graceful kill first — kill -9 can leave temp files, corrupt databases, and break locks.
Q8: What is piping in Linux? Give an example.
Model Answer: Piping (|) sends the output (stdout) of one command as the input (stdin) to the next command. It follows the Unix philosophy of "small tools that do one thing well, chained together." Example: ps aux | grep python | wc -l — this chain: (1) lists all processes, (2) filters only Python processes, (3) counts them. Real-world example at production: tail -f /var/log/nginx/access.log | grep "500" | awk '{print $7}' | sort | uniq -c | sort -rn — shows the most frequently failing URLs in real-time. Piping is what makes Linux CLI more powerful than any GUI.
Q9: What is the difference between a virtual machine and a Docker container?
Model Answer: A VM virtualizes the entire hardware — it has its own kernel, OS, and applications. Managed by a hypervisor (Type 1: ESXi, KVM; Type 2: VirtualBox). Heavy: GBs of overhead, minutes to boot. Provides complete isolation. A container shares the host OS kernel and only isolates the application layer using Linux namespaces (process isolation) and cgroups (resource limits). Lightweight: MBs of overhead, starts in seconds. Docker is the most popular container runtime. Use VMs when you need different OS kernels (Windows + Linux). Use containers for deploying applications consistently across environments. In production, Kubernetes orchestrates 1000s of containers on Linux servers.
Q10: What is MBR vs GPT? When should you use each?
Model Answer: MBR (Master Boot Record, 1983) supports max 2 TB disk size, 4 primary partitions, uses BIOS boot, and stores only one copy of the partition table (single point of failure). GPT (GUID Partition Table, 2000s) supports essentially unlimited disk sizes, 128 partitions, uses UEFI boot, and stores a backup partition table at the end of the disk. Rule: use GPT for all new systems. MBR is only needed for legacy BIOS systems or very old hardware. Any disk > 2 TB must use GPT. All modern operating systems (Windows 10+, Ubuntu 18.04+, macOS) fully support GPT.
💼 "Day 1 at a Tech Job" — What You'll Use From This Chapter
On day 1 at TCS/Infosys/Wipro: (1) You'll SSH into a Linux server — ssh username@server-ip. You need to navigate (cd, ls), read logs (tail -f, grep), and check system health (df -h, free -h, htop). (2) You'll deploy code — which requires chmod on scripts, chown for web server files, and understanding the file system layout. (3) You'll debug production issues — "Why is the server slow?" → htop (CPU), free -h (RAM), df -h (disk), tail -f error.log (application). (4) You'll write shell scripts to automate repetitive tasks — piping, redirection, and loops. The engineer who can do this in 5 minutes saves the team hours.
📂 GitHub Portfolio Tip
Create a repository called linux-cheatsheet with: (1) Your personal command reference (organized by category). (2) Screenshots from each lab exercise. (3) Your server deployment plan from Lab Exercise 5. (4) A shell script that generates a system health report (df -h, free -h, uptime, top 10 processes). Add a polished README.md. This shows recruiters you understand infrastructure — not just application code — which is exactly what DevOps/SRE roles demand.