Home 🐧 Linux Linux & Bash

What is
Linux & Bash?

From the locked recipe books of proprietary systems to the open kitchens of the modern world — a complete guide to the operating system powering 90% of the internet, and the command language that controls it.

📅 Updated 2026 ⏱️ ~24 min read 🐧 Linux · Bash · DevOps
🐧

Born 1991

Created by Linus Torvalds

🔓

Open Source

The recipe is free for everyone

🌍

90% of Servers

Powers the modern internet

⌨️

Bash Shell

Human-to-kernel translator

📜

The Simple Explanation

The Age of Locked Recipe Books

Before Linux, computing was like a restaurant where the recipe was kept in a locked safe. You were allowed to eat the food, but forbidden from seeing how it was cooked or changing the ingredients. Early computers in the 1940s and 1950s had no operating system at all — programs were loaded one at a time using physical switches. Then came "batch processing" — a community kitchen that allowed only one person inside at a time, and if a tool broke, the user had to fix it themselves.

In 1991, a Finnish student named Linus Torvalds created a free, open alternative — the Linux kernel. He opened the recipe book for everyone.

🔒 Three Problems With Proprietary Systems

📖

Locked Recipes

The source code was kept secret. Users could not fix bugs or add features — they had to wait for the company to decide to make changes. The kitchen's instructions were hidden in a locked safe.

💸

High Costs

Systems were extremely expensive and inaccessible to regular people. In 1989, a portable computer from a major company cost as much as a luxury kitchen installation — out of reach for most of the world.

🍞

Lack of Portability

A program written for one brand of computer would not run on another. Like a toaster that only works with one specific brand of bread — you were permanently locked into one manufacturer's ecosystem.

Proprietary vs. Open Source — A Comparison

Linux changed every dimension of the equation when it opened the recipe book in 1991.

🧅

The Simple Explanation

The Walnut Analogy

An operating system is like a walnut. At the very center is the kernel — the seed inside the hard shell. Surrounding the kernel is the shell — the tough outer layer. The shell translates your words into instructions the seed understands. You, the user, are outside holding the whole walnut, talking to the shell.

The kernel never speaks directly to you. It speaks to the hardware. Bash is the shell — the translator that converts plain English commands into the electrical signals the kernel understands.

🍳 The Kitchen Analogy: Full Component Map

ComponentKitchen AnalogyTechnical Function
HardwareThe Physical Kitchen (Stove, Sink, Fridge)The electronic circuits and physical parts of the computer
KernelThe Master ChefCore software that manages all hardware resources directly
Shell (Bash)The Waiter / TranslatorInterface translating human commands into kernel instructions
UserThe CustomerThe person giving instructions at the terminal
ApplicationThe Specific RecipeA program designed for a specific task (browser, editor, etc.)

🧠 The Kernel's Four Critical Areas

🧠 Memory Management

The kernel decides which program gets to use the computer's RAM — the temporary space where active information lives. It ensures programs don't steal each other's memory, like the Master Chef deciding which dish gets the biggest pot.

⚙️ Process Management

The kernel ensures every program gets a fair turn to use the CPU. Like a chef managing multiple dishes on the stove — nothing burns, nothing is ignored. Each process takes turns sharing the processor.

🔌 Device Drivers

The kernel acts as a universal translator for hardware. It knows how to talk to your screen, your keyboard, your printer — so your programs don't have to learn a different language for every brand of device.

🛡️ System Security

The kernel acts as a guard — enforcing that one user cannot look at another user's private files or break the computer. It validates every request against the permission rules before executing it.

Key Insight

Why We Need the Shell

The kernel is incredibly powerful, but it doesn't speak human languages. It only understands complex electrical signals and binary numbers. Bash (Bourne Again SHell) is the world's most popular shell — a waiter that takes your order in plain English (ls -la) and translates it into the technical language the Master Chef understands.

what happens when you type a command
# You type (human language)
$ ls -la /home/alice

# Bash (the waiter) translates it → sends to kernel
# Kernel reads the file system → returns data
# Bash formats the result → prints it to your screen

drwxr-xr-x alice alice 4096 Jan 01 Documents
-rw-r--r-- alice alice 512 Jan 01 notes.txt
🌳

The Simple Explanation

One Giant House With Named Rooms

Unlike Windows where different drives get letters like C: or D:, Linux puts everything into one single structure called the root — represented by a single forward slash /. Every file, program, and even piece of hardware is a branch on this giant tree starting from /.

Think of the computer as a large house. The file system is the way the rooms and cabinets are arranged. Every room has a specific purpose, and every item has a path — the list of rooms you walk through to find it.

🏠 The Essential Rooms of the Linux House

/ — the root of everything
/ ← The front door of the entire house
├── bin/ ← Essential tool drawer (ls, cp, mv...)
├── sbin/ ← Basement — heavy tools for the owner only
├── etc/ ← The Rule Book — config files for every program
├── home/ ← The Bedrooms — one folder per regular user
│ └── alice/ ← Alice's private room
├── root/ ← Owner's Private Suite (superuser only)
├── var/ ← The House Logbook (logs, mail queues)
├── tmp/ ← Scrap Paper Pile (cleared on reboot)
├── dev/ ← Hardware Closet (keyboard, mouse as files)
├── proc/ ← House Sensors — live kernel data (virtual)
└── sys/ ← More sensors — hardware state (virtual)
/bin

The Essential Tool Drawer

Contains "binaries" — the basic executable tools every user needs. Commands like ls, cp, mv, cat. If these break, the house is unusable.

/sbin

The Basement

System binaries for heavy maintenance. Only the root (owner) user should access these — like the boiler or the fuse box. Regular users have no business here.

/etc

The Rule Book

Configuration files for every installed program. Like a manual on the wall telling the chefs what temperature the oven should be. Change a file here and the entire program's behaviour changes.

/home

The Bedrooms

Personal folders for every regular user. /home/alice, /home/bob. Only the room's owner can enter. Your Documents, Pictures, and config files live here.

/root

The Owner's Private Suite

The home folder for the superuser — kept completely separate from regular bedrooms for extra security. The most powerful account on the system lives here.

/var

The House Logbook

Stores variable, ever-changing files: system logs, mail queues, databases. Like a logbook recording when the mail arrived and if any lightbulbs burned out.

/tmp

The Scrap Paper Pile

Temporary files that programs create while working. The system wipes this clean on every reboot — like throwing away the notepad after doing a quick calculation.

/dev

The Hardware Closet

In Linux, every piece of hardware is treated as a file. Your keyboard is /dev/input/keyboard. Your hard drive is /dev/sda. Everything is a file — a fundamental Linux philosophy.

/proc & /sys

The House Sensors — Virtual Rooms

These directories don't physically exist on the hard drive. They are created live by the kernel and show real-time information about what the brain is thinking right now — CPU usage, memory, running processes. Like sensors on the wall showing current temperature and humidity.

🧭

The Simple Explanation

Opening Your Eyes in the House

Every Bash command follows a three-part pattern: the Command Name (what to do), the Options/Flags (how to do it — prefixed with a dash), and the Argument (what to do it to). Master these three navigation commands and you can find anything in the Linux file system.

👁️ ls — List: Open Your Eyes

The ls command shows you what is inside a folder. Like opening your eyes to see everything in a room. It is the first command every Linux user learns.

OptionNameWhat It Does
-aAllShows hidden items (files starting with a dot) — like a secret drawer under the counter
-lLongShows details: permissions, owner, file size, and last-modified timestamp
-hHuman-readableChanges raw byte counts into readable units: KB, MB, GB
-RRecursiveLooks inside every folder and every folder inside those — a full master search
-tTimeSorts items by when they were last modified — newest first
-SSizeSorts items by file size — largest first
-rReverseReverses the sort order of any other flag
ls examples
# Basic — what's in this folder?
$ ls
Documents Downloads notes.txt script.sh

# Professional combo: long + human + hidden files
$ ls -lah
drwxr-xr-x alice alice 4.0K Jan 10 Documents
-rw-r--r-- alice alice 512 Jan 10 notes.txt
-rw------- alice alice 256 Jan 09 .bash_history ← hidden

🚶 cd — Change Directory: Walk Through Doors

Essential cd Shortcuts

  • cd DocumentsWalk into the Documents room
  • cd ..Go back one level — the parent room
  • cd ~Instantly return to your home bedroom
  • cd -Return to the previous room (like a back button)
  • cd /Jump to the front door — the root of everything

Absolute vs. Relative Paths

# Absolute — starts from /
$ cd /home/alice/Documents

# Relative — from where you are now
$ cd Documents/Projects

📍 pwd — Print Working Directory: Where Am I?

When you get lost deep inside nested folders, pwd tells you exactly where you are — the complete path from the front door / all the way to your current room. Essential when running scripts that need to know their own location.

pwd
$ pwd
/home/alice/Documents/Projects/website

# You are now five rooms deep from the front door
✂️

The Simple Explanation

Creating, Moving, and Destroying

Navigation lets you look around. Action commands let you change things — build new rooms, make copies of items, move things from one room to another, and delete them. The most important rule: there is no Trash Can on a Linux server. Deleted means gone forever.

🏗️ mkdir — Make Directory

Creates a new room (folder). The -p flag builds an entire hallway of nested rooms at once — no need to create them one by one.

$ mkdir Reports ← one room
$ mkdir -p Projects/2026/January ← full hallway at once

📄 touch — Create a Blank File

Creates a new, empty file — like placing a blank sheet of paper on the desk. Also updates a file's "last modified" timestamp without changing its contents.

$ touch notes.txt ← new blank file
$ touch notes.txt ← updates timestamp (file unchanged)

📋 cp — Copy

Makes a duplicate — like putting a photo in a copy machine. The original stays untouched; a new copy appears at the destination.

OptionNamePractical Use
-rRecursiveCopies an entire folder and all its contents — essential for directories
-pPreserveKeeps the original owner, timestamps, and permissions on the copy
-uUpdateOnly copies if the source is newer than the existing copy — smart syncing
$ cp notes.txt backup/notes.txt ← single file
$ cp -rp Projects/ /backup/Projects/ ← whole folder, preserved

🚚 mv — Move and Rename

In Linux, moving a file and renaming it are the same command. You're just picking up an item and putting it somewhere else or giving it a new label. The original disappears from its old location.

$ mv notes.txt Documents/notes.txt ← move to a different room
$ mv old_name.txt new_name.txt ← rename in the same room

🗑️ rm — Remove ⚠️ No Undo

Deletes files permanently. There is no Trash Can, no Recycle Bin, no Undo button on a server. Once gone, it's gone. This is the most dangerous command a beginner can type.

OptionNameWhy It's Used
-iInteractive✓ Recommended for beginners — asks "Are you sure?" before each deletion
-rRecursiveDeletes an entire folder and everything inside it — all sub-folders too
-fForce⚠️ Deletes without asking, even protected files. Use with extreme caution
$ rm -i notes.txt ← safe: asks before deleting
rm: remove regular file 'notes.txt'? y

$ rm -rf Projects/ ← dangerous: deletes entire folder silently
⚠️ No output. No confirmation. It's just gone.
🔍

The Simple Explanation

Reading Books and Finding Words

Linux servers produce enormous amounts of text: log files, config files, output data. You need tools to read them and to filter out exactly the line you're looking for in a file with thousands of entries. These three commands are your reading glasses and magnifying glass.

📖 cat — Concatenate: Read the Whole Book

Displays the entire contents of a file on screen. Like opening a book and reading every page at once. Best for short files — large files will scroll past too fast to read.

$ cat notes.txt ← print whole file
$ cat -n notes.txt ← with line numbers
$ cat file1.txt file2.txt ← concatenate (join) multiple files

🔎 grep — The Magnifying Glass

Searches for a specific word or pattern inside a file or stream. Like using a magnifying glass to find a specific name in a giant phone book. One of the most powerful and frequently used commands in Linux.

-i

Case-Insensitive

Finds "Error", "ERROR", "error"

-v

Invert Match

Shows everything EXCEPT the word

-r

Recursive

Searches every file in every folder

# Find "error" in a log file (case-insensitive)
$ grep -i "error" /var/log/syslog

# Search every file in the logs folder recursively
$ grep -r "Failed login" /var/log/

# Show all lines that DON'T contain "debug"
$ grep -v "debug" app.log

📰 head & tail — Peek at the Beginning or End

head shows the first 10 lines of a file. tail shows the last 10. Both accept -n to specify a custom number. tail -f is the professional's live monitoring tool — it watches a file and instantly prints new lines as they appear.

$ head -n 5 server.log ← first 5 lines
$ tail -n 20 server.log ← last 20 lines

# The professional live-monitoring trick:
$ tail -f /var/log/syslog ← live news ticker
Jan 10 14:32:01 server sshd: Accepted login for alice
Jan 10 14:32:15 server cron: Running daily backup...
🔐

The Simple Explanation

The Three Keys and Three Groups

In a multi-user house, every file has three types of keys — Read, Write, and Execute — and three groups of people who might hold those keys: the Owner (you), the Group (your team), and Others (everyone else). The combination determines exactly who can do what.

🗝️ The Three Keys

👁️

r = 4

Read

The power to look at a file or see what's inside a folder. Without this key, the file is invisible to you.

✏️

w = 2

Write

The power to change a file, delete it, or add new items to a folder. A crucial key to protect — grant it sparingly.

▶️

x = 1

Execute

The power to run a file as a program, or to cd into a folder. A script without this key just sits there — it cannot run.

🏷️ Reading the Permission Label

When you run ls -l, you see a string like -rwxr-xr--. This is the Lock Label, broken into four parts:

-rwx r-x r-- alice staff 4096 Jan 10 script.sh

└─────┘ └─────┘ └─────┘
OWNER GROUP OTHERS
└── file type (- = file, d = directory)

🔢 The Numeric Code System

NumberSymbolKeys HeldPlain English
7rwx4+2+1Can read, write, and execute — full control
6rw-4+2Can read and modify, but not run as a program
5r-x4+1Can read and run, but not modify
4r--4Can only look at the file — read-only
0---0Cannot do anything — completely locked out
chmod examples
# Give owner all keys (7), group and others read+run (5)
$ chmod 755 script.sh

# Private file: only owner can read/write (6), no one else (0)
$ chmod 600 ~/.ssh/id_rsa

# Change the owner of a file
$ chown alice:developers project.txt
🏭

The Simple Explanation

The Factory Assembly Line

One of Linux's most powerful ideas is connecting tools together. Imagine a factory assembly line: the first worker makes a toy, the second worker paints it, the third puts it in a box. The Pipe | is the conveyor belt. Each command produces output that becomes the next command's input — creating powerful chains from simple tools.

🚰 The Three Standard Streams

⌨️

stdin (0)

Standard Input

The hose where ingredients come in. Usually the keyboard — but can be redirected from a file or another command's output.

🖥️

stdout (1)

Standard Output

The hose where the finished product comes out. Usually the screen — but can be redirected to a file or piped to another command.

🚨

stderr (2)

Standard Error

A separate "Oops!" hose. Error messages travel here independently so they can be captured separately from successful output.

🔗 The Connector Symbols

|

Pipe — The Conveyor Belt

Connects the stdout of one command directly into the stdin of another. Chains commands into powerful assembly lines.
ls | grep "homework" — list files, then filter for ones containing "homework".

>

Output Redirect — Overwrite

Takes the output and pours it into a file instead of the screen. Overwrites everything that was already there. Like replacing a notepad's contents entirely.
ls -la > file_list.txt

>>

Append Redirect — Add to End

Takes the output and adds it to the end of a file without erasing old content. Like flipping to the next blank page in a notepad.
echo "new entry" >> logfile.txt

2>

Error Redirect — Capture Mistakes

Takes only the "Oops!" (stderr) messages and saves them to a separate file. Keeps your output clean while preserving error details for debugging.
./script.sh 2> errors.log

pipe chains — real-world examples
# Count how many times "error" appears in a log
$ cat server.log | grep -i "error" | wc -l
47

# List the 5 largest files in the current directory
$ ls -lS | head -n 5

# Find unique IP addresses in an access log
$ cat access.log | awk '{print $1}' | sort | uniq
🏪

The Simple Explanation

The Safe Neighbourhood Store

In traditional systems, you downloaded software from random websites and hoped it wasn't a virus. Linux uses a Package Manager — a giant, safe, curated store for your neighbourhood. Every item has been checked for safety. The delivery truck (package manager) even knows which batteries each toy needs and fetches them automatically.

🍦 Distributions — Different Flavours of Linux

Because Linux is Open Source, many different groups have created their own versions — called distros. They're all Linux (all ice cream) but with different tools and communities (different toppings).

Distribution FamilyPackage ManagerBest Used In
Debian / UbuntuaptMost home computers, cloud servers, beginner-friendly
Red Hat / Fedora / CentOSdnf or yumLarge enterprises, AWS AMIs, corporate environments
Arch LinuxpacmanExperts who want to build a fully custom system from scratch
apt — the Ubuntu/Debian delivery truck
# Update the store's catalogue (check for new versions)
$ sudo apt update

# Install a package (apt gets it + all its "batteries")
$ sudo apt install vlc

# Upgrade all installed packages to their latest versions
$ sudo apt upgrade

# Remove a package (but keep its config files)
$ sudo apt remove vlc

📝 Text Editors — Writing in the Terminal

To truly use Linux professionally, you must be able to create and edit config files in the terminal. Two editors dominate: one is beginner-friendly, one is legendary.

📗

Beginner Friendly

Nano

The friendly notepad. Shows shortcut keys at the bottom of the screen. What you see is what you get — just type, and it appears on screen.

$ nano myfile.txt
# Type your content
Ctrl+O → Save (Write Out)
Ctrl+X → Exit
🧙

The Wizard's Wand

Vim

A modal editor with different modes for different tasks. Hard to learn, but incredibly fast once mastered. Vim is on virtually every Linux server on earth.

$ vim myfile.txt
i → Insert Mode (type here)
Esc → Back to Normal Mode
:wq → Save and Quit
:q! → Quit WITHOUT saving
dd → Delete current line

The Simple Explanation

The Morning Routine

When you press the power button, the computer doesn't just "turn on." It follows a strict, sequential Morning Routine — waking up each system in the right order before the next one can start. Like a chef who must first unlock the building, then turn on the stove, before the team can arrive and cook.

🌅 The Four Stages of Boot

1

BIOS — The Alarm Clock

Firmware Level

A tiny program permanently burned into a chip on the motherboard. It wakes up when power arrives and performs a POST (Power-On Self-Test) — checking that the stove, the refrigerator, and the sink all exist and are working. Then it looks for a bootable device (a hard drive or USB).

2

MBR & GRUB — Picking Your Outfit

Bootloader

The MBR (Master Boot Record) is a tiny sector at the very beginning of the hard drive. It contains enough code to find and launch GRUB (the bootloader). If you have both Windows and Linux installed, GRUB shows you a menu to choose which operating system to wear today. This is the wardrobe stage.

3

Kernel — The Master Chef Wakes Up

OS Core

GRUB loads the Linux kernel into RAM. The kernel immediately takes control of all hardware — it starts the memory manager, initialises device drivers, and sets up the file systems. This is the Master Chef putting on their apron, turning on every burner, and stocking the workspace.

4

Init & Services — Opening for Business

Userspace

The very first program the kernel runs is init (Process ID = 1). On modern systems this is systemd. Init is the head manager who opens the kitchen for business — it starts all background services in the correct order: networking, the login screen, the web server, the database. When init is done, your system is ready to use.

$ systemctl status nginx ← check a service
$ systemctl start nginx ← start a service
$ systemctl enable nginx ← start on boot automatically

Summary

From User to Master

Linux and Bash represent one of humanity's greatest collaborative achievements — an operating system that runs the world, built openly by millions of people, available to everyone for free. By understanding all its layers, you transform from a passive user into an active master of any machine.

Architecture: Kernel as Master Chef, Bash as the Waiter
File System: One tree from /, every room with a purpose
Navigation: ls · cd · pwd — open your eyes and move
Permissions: Three keys (rwx) for three groups — precision access control
Pipes: Chain simple tools into powerful assembly lines with |
Boot Process: BIOS → GRUB → Kernel → Init — the Morning Routine

The recipes are now open for everyone. The tools can be connected in infinite ways. The kitchen is yours — start cooking.