Day 02 / 30 — Theory Notes

Linux — Theory Notes

Everything about Linux — what it is, how it works, why it matters. Beginner to advanced, all in one place. No commands — pure concepts.

What is LinuxWhy DevOps needs Linux ArchitectureFile System Everything is a FileUsers & Groups PermissionsProcesses Package ManagementNetworking Shell & ScriptingLinux in DevOps
01
What is Linux?

Linux is a free, open-source operating system. Just like Windows or macOS runs your laptop, Linux runs computers — but it's free, open, and can run on anything from a Raspberry Pi to the world's most powerful servers.

Created in 1991 by Linus Torvalds — a Finnish student who wanted a free alternative. He released the source code publicly and the world built upon it. Today Linux powers over 90% of the internet's servers, all Android phones, supercomputers, and almost every cloud platform.

💡 Simple definition: Linux is the operating system that runs the internet. When you visit any website, there's a very high chance a Linux server is sending you that page.

Linux vs Windows vs macOS

Linux
Free & open source. Runs on everything. No GUI needed — terminal is enough. Highly customizable. Preferred for servers, DevOps, cloud.
Windows / macOS
Commercial OS. GUI-focused. Made for personal computers. Not ideal for servers — expensive licensing, heavy on resources.
🐧 Linux Distros: Linux is just the kernel. Different groups package it differently — called distros. Popular: Ubuntu (beginner), CentOS/RHEL (enterprise), Debian (stable), Alpine (tiny, used in Docker), Amazon Linux (AWS).
02
Why DevOps Needs Linux

In DevOps, you work with servers, containers, cloud platforms, and automation tools — all of which run on Linux. Docker runs on Linux. Kubernetes runs on Linux. AWS, Azure, GCP servers run Linux. CI/CD pipelines run on Linux. There is no escaping it.

Servers90%+ of web servers run Linux. When you SSH into a production server, you land in a Linux terminal. You must be comfortable there.
ContainersDocker containers are lightweight Linux environments. Every Dockerfile starts with a Linux base image. Linux knowledge = container knowledge.
AutomationShell scripts, Ansible playbooks, Terraform configs — all run on Linux. Automation is impossible without knowing Linux.
CloudAWS EC2, Google Compute Engine, Azure VMs — default OS is Linux. You interact with cloud resources via Linux terminal.
CostLinux is free. No licensing fees. Companies run thousands of Linux servers in cloud — economical at massive scale.
🚀 Bottom line: If Git is the starting point of DevOps, Linux is the ground everything runs on. Without Linux, there is no DevOps.
03
Linux Architecture

Linux is built in layers. Each layer communicates with the one below it. Understanding this helps you understand how Linux actually works under the hood.

Apps
User / Applications Layer
Programs you run — browser, Python script, Docker. These are user space programs. They don't directly touch hardware — they go through the layers below.
Shell
Shell — Your Interface
You type commands, the shell interprets them and sends instructions to the kernel. Common shells: bash (most common), zsh, sh. Terminal = how you access the shell.
Kernel
Kernel — The Heart of Linux
Manages everything — CPU, memory, storage, network, processes. The bridge between software and hardware. When Linus created "Linux" — he created the kernel. Everything else was built around it.
HW
Hardware
Physical machine — CPU, RAM, disk, network card. Kernel talks to hardware via device drivers. Your application never touches hardware directly.
💡 The chain: You type command → Shell interprets → Kernel executes → Hardware responds. Every single Linux operation follows this path.
04
Linux File System

Linux has a single tree structure starting from root (/). Everything — files, folders, devices, processes — lives under this single root. No C:\ or D:\ drives like Windows. Just one unified tree.

💡 Root is NOT the root user. The / symbol = top of filesystem tree. The root user = admin user. Same word, different meanings.

Important Directories — What lives where

/Root — very top of filesystem. Everything starts here.
/homeHome directories for all regular users. Your personal files live here. /home/pallavi is your folder.
/rootHome directory for the root (admin) user only. Separate from /home.
/etcConfiguration files for system and all software. nginx config, SSH config, user accounts — all here. Critical folder.
/varVariable data — things that change constantly. Log files (/var/log), databases. When debugging, always check /var/log.
/bin, /usr/binExecutable programs. When you type ls or git — Linux looks here to find and run them.
/tmpTemporary files — cleared on reboot. Never store important data here.
/procVirtual filesystem — not real files on disk. Live info about running processes. /proc/cpuinfo shows CPU details.
/devDevice files. Hard disk = /dev/sda. USB = /dev/sdb. Hardware appears as files in Linux.
/optOptional software. Third-party apps installed manually go here. Java, custom tools.
05
Everything is a File

This is one of the most fundamental — and surprising — Linux concepts. In Linux, everything is treated as a file. Not just documents and folders — hardware devices, network connections, processes, system info — all are files.

Regular filesText files, scripts, images, binaries. Normal files you create and edit.
DirectoriesFolders — but in Linux, a directory is also a file that contains references to other files.
Device filesKeyboard, hard disk, USB — all appear as files in /dev. To read from a device, you read its file.
Socket filesNetwork connections between processes are files. Docker communicates via /var/run/docker.sock — a socket file.
Symbolic linksShortcuts — a file that points to another file. More powerful than Windows shortcuts. Called symlinks.
💡 Why this matters in DevOps: When Docker mounts a volume, when Kubernetes injects a config, when nginx reads a config — it's all just file operations. This concept makes advanced DevOps much simpler to understand.
06
Users & Groups

Linux is a multi-user system. Multiple people (or processes) can use the same machine simultaneously. Linux keeps them separate and secure using users and groups.

Root userThe superuser — unrestricted access to everything. Can install software, change any file, manage users. Like the God of the system. Use with extreme care.
Regular usersNormal users with limited permissions. Can only access their own files and approved resources. Best practice: never run as root in daily use.
GroupsA collection of users. Permissions assigned to a group — all members get that permission. The docker group lets users run Docker without sudo.
sudo"Super User Do" — temporarily run one command with root privileges. Safer than logging in as root. Power for one command only.
Service usersSpecial system users created for services — nginx user, postgres user. No login shell — only exist to run processes securely.
⚠️ Principle of least privilege: Every user and process should have only the minimum permissions needed — nothing more. Limits damage if something is compromised.
📌 User info stored in: /etc/passwd (users), /etc/shadow (encrypted passwords), /etc/group (groups). Plain text files — Linux config is always human-readable.
07
File Permissions

Every file in Linux has permissions controlling who can read, write, or execute it. This is Linux's core security model. As a DevOps engineer, wrong permissions = broken deployments or security holes.

The permission string

When you list files, you see: -rwxr-xr-- — here's how to read it:

permission string — 10 characters
-
r
w
x
r
-
x
r
-
-
type
owner (user)
group
others
r = read
View file content or list folder. Value: 4
w = write
Modify or delete the file. Value: 2
x = execute
Run as program/script. Value: 1

Numeric permissions

777rwxrwxrwx — everyone can do everything. Never use on production — huge security risk.
755rwxr-xr-x — owner full access, others read+execute. Standard for executables and directories.
644rw-r--r-- — owner read/write, others read only. Standard for regular files.
600rw------- — only owner read/write. Used for SSH private keys.
400r-------- — read only by owner. AWS .pem key files use this. Maximum restriction.
💡 How to calculate: r=4, w=2, x=1. Add them up per group. rwx=7, r-x=5, rw-=6. So 755 = rwxr-xr-x. 644 = rw-r--r--.
08
Processes

A process is a running program. Every command you run, every service on a server — each is a process. Linux assigns every process a unique PID (Process ID).

PIDProcess ID — unique number for every running process. PID 1 is always the first process (systemd). Used to manage and kill processes.
ForegroundProcess running in your terminal — you see its output. Blocks your terminal until done. Can't run other commands while it runs.
BackgroundProcess running silently behind the scenes. Terminal stays free. Long-running servers use this.
DaemonA background service that starts on boot and runs continuously. nginx, sshd, docker — all are daemons. Managed by systemd.
ZombieA finished process whose entry hasn't been cleaned up. Harmless individually — parent process must clean up children.
OrphanProcess whose parent was killed. Linux adopts it under PID 1 (systemd) automatically.
💡 systemd is the modern init system (PID 1) — first process Linux starts. It manages all services (start, stop, restart, enable on boot). In DevOps, you'll use systemctl constantly to manage nginx, docker, ssh, etc.
09
Package Management

Installing software on Linux is done through a package manager — not by downloading .exe files. Package managers handle downloading, installing, updating, and removing software along with all dependencies automatically.

apt / apt-get
Used on Debian / Ubuntu. Most common for beginners. apt is the newer, friendlier version.
yum / dnf
Used on RHEL / CentOS / Amazon Linux — enterprise servers. dnf is modern replacement for yum.
apk
Used in Alpine Linux — the tiny distro used in Docker containers. Extremely fast and minimal.
snap / flatpak
Universal package formats that work across all distros. Package includes all dependencies — no conflicts.
💡 How it works: Package managers pull from online repositories — trusted servers maintained by the distro. Always run update before install to get the latest package list from the repo.
10
Linux Networking Basics

In DevOps, servers constantly communicate over networks. Understanding these concepts is essential for troubleshooting connectivity, configuring servers, and securing deployments.

IP AddressUnique address for every device on a network. Private IPs (192.168.x.x, 10.x.x.x) are inside your network. Public IPs are reachable from internet.
PortNumber identifying a specific service on a machine. Port 22=SSH, 80=HTTP, 443=HTTPS, 3306=MySQL, 6443=Kubernetes. IP + Port = exact destination.
SSHSecure Shell — encrypted way to remotely control a Linux machine via terminal. How you manage all cloud servers. Uses port 22 and your SSH key pair.
DNSDomain Name System — translates domain names (google.com) to IPs. Like a phonebook for the internet. /etc/resolv.conf stores DNS config.
FirewallControls which traffic is allowed in/out. Linux uses iptables (advanced) or ufw (simple). In cloud: Security Groups act as firewall.
localhostAlways refers to your own machine. IP 127.0.0.1. App connecting to "localhost:3000" is connecting to itself.
💡 In DevOps: SSH into servers to configure them. Open ports so services are accessible. Configure DNS so app is reachable by domain. Use firewalls to block unwanted traffic. Linux networking is the backbone of all of this.
11
Shell & Shell Scripting

The shell is your interface to Linux. You type commands, the shell runs them. But the real power comes from shell scripting — multiple commands in a file, run automatically. This is the foundation of automation in DevOps.

bashBourne Again Shell — most common shell on Linux. Default on Ubuntu, CentOS, Amazon Linux. When you write shell scripts, you almost always write bash scripts.
zshModern shell with more features. Default on macOS. Popular for its plugins and themes (oh-my-zsh).
shOriginal POSIX shell. Most basic, most compatible. Scripts in sh run on any Unix system.

What shell scripts can do

Automate tasksBackup files nightly, clean logs weekly, deploy code on every push — anything repetitive can be scripted.
Server setupScript that installs nginx, configures it, starts it, enables on boot — run it on any new server in seconds.
CI/CD pipelinesGitHub Actions, Jenkins — they all run shell scripts internally. Build, test, deploy — all automated shell commands.
MonitoringScripts that check disk space, CPU usage, service status and send alerts when something is wrong.
💡 Shebang line: Every bash script starts with #!/bin/bash — tells Linux which shell to use. Without it, Linux doesn't know how to interpret the file.
Variables, loops, conditions, functions — bash supports all programming constructs. Shell scripting is a complete programming environment built into every Linux system.
12
Linux in DevOps — The Big Picture

Linux is not just one tool in DevOps — it is the foundation everything is built on. Every technology in this 30-day challenge runs on Linux or relies on Linux concepts.

Git
Day 1 — Git ✓
Git runs on Linux. GitHub Actions runs on Linux runners. All git operations happen in a Linux shell.
Linux
Day 2 — Linux ← You are here
The OS that runs everything. File system, permissions, processes, networking, shell scripting. Foundation of the entire stack.
Docker
Upcoming — Docker
Docker containers are Linux processes with isolated filesystems and namespaces. Docker IS Linux under the hood. Your Linux knowledge directly applies.
K8s
Upcoming — Kubernetes
Kubernetes manages Linux containers at scale. Every node in a K8s cluster is a Linux machine. SSH, permissions, processes — all Linux concepts apply.
Cloud
Upcoming — Cloud (AWS / Azure / GCP)
Cloud VMs are Linux servers. AWS EC2 instance = a Linux machine. You SSH in and manage it with Linux commands.
🚀 The chain: Linux → Docker → Kubernetes → Cloud → CI/CD → Full DevOps Engineer. It all starts here on Day 2.
💡 Daily habit: Use Linux terminal for everything — even on your personal laptop (WSL on Windows, Terminal on Mac). The more time in the terminal, the more comfortable you become. Comfort = speed = confidence.
#30DaysOfDevOps #Day2 #Linux #DevOps #SysAdmin #LearnInPublic #100DaysOfCode #OpenSource