linux

Linux is a free, open-source, Unix-like operating system kernel — first released by Linus Torvalds in 1991 — that today powers everything from smartphones (Android) and web servers to supercomputers and embedded devices. Understanding it deeply means understanding how processes, memory, files, and permissions actually work under the hood.

Contents

  1. Linux Architecture
  2. Filesystem Hierarchy Standard
  3. Users, Groups & Permissions
  4. Process Management
  5. Shell & Scripting
  6. Package Management
  7. Networking Basics
  8. systemd & Services
  9. Command Cheat Sheet
  10. External Learning Resources

Linux Architecture

Linux follows a layered design. At the very bottom sits the kernel, which talks directly to hardware; above it sit system libraries and utilities; and above that, the applications you actually run.

Filesystem Hierarchy Standard (FHS)

Almost everything in Linux is represented as a file — including devices and process information. The FHS defines a standard directory layout so that software behaves predictably across distributions.

Path Purpose
/bin, /usr/binEssential user command binaries (ls, cp, bash).
/sbin, /usr/sbinSystem administration binaries (fdisk, reboot).
/etcSystem-wide configuration files (no binaries).
/devDevice files (e.g. /dev/sda, /dev/null).
/procVirtual filesystem exposing kernel & process info in real time.
/sysVirtual filesystem exposing kernel/device driver state (sysfs).
/varVariable data: logs, caches, spool files.
/homePer-user personal directories.
/tmpTemporary files, usually cleared on reboot.
/lib, /usr/libShared libraries needed by binaries in /bin and /sbin.
/optOptional third-party / add-on software packages.
/bootKernel image, initramfs, and bootloader files.
/mnt, /mediaMount points for temporary and removable filesystems.

Users, Groups & Permissions

Every file has an owner, a group, and a permission set for owner / group / others, each with read (r), write (w), execute (x) bits. Permissions can be represented symbolically (rwxr-xr--) or numerically in octal.

Octal Symbolic Meaning
7rwxRead + Write + Execute
6rw-Read + Write
5r-xRead + Execute
4r--Read only
755rwxr-xr-xCommon for executables/scripts.
644rw-r--r--Common for regular files.
permissions.sh
# view permissions
ls -l file.txt
# -rw-r--r-- 1 dipansu dipansu 512 Sep 26 10:00 file.txt

# change permissions
chmod 755 deploy.sh        # numeric mode
chmod u+x deploy.sh        # symbolic mode: add execute for owner

# change ownership
chown dipansu:dev file.txt

# add a user to a group
sudo usermod -aG docker dipansu

# check current user & groups
whoami
groups

Process Management

A process is a running instance of a program. The kernel scheduler decides which process runs on the CPU and for how long, using priority/nice values and scheduling classes.

process_management.sh
# list running processes
ps aux
ps -ef --forest         # show process tree

# live resource usage
top
htop                     # nicer, interactive (may need install)

# send signals
kill -15 1234            # SIGTERM: ask process 1234 to terminate gracefully
kill -9 1234              # SIGKILL: force kill (uncatchable)
pkill -f "python app.py"  # kill by matching command name

# run in background / detach from terminal
long_task.sh &
disown
nohup long_task.sh &> out.log &

# change scheduling priority
nice -n 10 ./batch_job.sh
renice -n 5 -p 1234

Shell & Scripting

The shell is both an interactive command interpreter and a scripting language. Bash scripts let you automate repetitive sysadmin and dev tasks.

backup.sh
#!/usr/bin/env bash
set -euo pipefail   # exit on error, unset var, or failed pipe

SRC_DIR="/home/dipansu/projects"
DEST_DIR="/backup/$(date +%Y-%m-%d)"

mkdir -p "$DEST_DIR"

for file in "$SRC_DIR"/*.log; do
    if [[ -f "$file" ]]; then
        cp "$file" "$DEST_DIR/"
        echo "Backed up: $file"
    fi
done

echo "Backup complete -> $DEST_DIR"

Package Management

Different distributions use different package managers, but the underlying goals — installing, updating, and removing software with dependency resolution — are the same.

Distro Family Package Manager Example Commands
Debian / UbuntuAPT (.deb)apt update && apt install nginx
RHEL / Fedora / CentOSDNF / YUM (.rpm)dnf install nginx
Arch LinuxPacmanpacman -S nginx
Any distroSnap / Flatpaksnap install code --classic
Embedded (Yocto)BitBake recipesbitbake core-image-minimal

Networking Basics

networking.sh
ip addr show                  # list interfaces & IPs
ip route                      # routing table
ss -tulpn                      # listening TCP/UDP sockets + owning PID
curl -I https://example.com    # quick HTTP HEAD request
ping -c 4 8.8.8.8               # basic reachability test
dig example.com +short          # DNS lookup
scp file.txt user@host:/path/   # secure copy over SSH

systemd & Services

Most modern distributions use systemd as PID 1 — it manages the boot process, services (units), sockets, timers, and logging (via journald).

systemd.sh
systemctl status nginx          # check service status
systemctl start nginx           # start a service now
systemctl enable nginx          # start automatically at boot
systemctl restart nginx
journalctl -u nginx -f          # follow live logs for a unit
journalctl -xe                  # recent logs with explanations

# a minimal custom unit file: /etc/systemd/system/myapp.service
# [Unit]
# Description=My App
# After=network.target
#
# [Service]
# ExecStart=/usr/local/bin/myapp
# Restart=on-failure
#
# [Install]
# WantedBy=multi-user.target

Command Cheat Sheet

Command What It Does
ls -laList all files (including hidden) with details.
cd -Jump back to the previous working directory.
find / -name "*.log"Recursively search for files by name.
grep -rn "TODO" .Recursively search file contents with line numbers.
du -sh *Show disk usage of each item in the current directory.
df -hShow free/used disk space per mounted filesystem.
tar -czvf out.tar.gz dir/Compress a directory into a gzip tarball.
chmod +x script.shMake a script executable.
ln -s target linkCreate a symbolic link.
watch -n 2 df -hRe-run a command every N seconds.
history | grep sshSearch your shell command history.
man chmodOpen the manual page for a command.

Quiz

You need to gracefully ask a misbehaving process to shut down (allowing it to clean up), rather than force-killing it instantly. Which signal should you send?

External Learning Resources

Reading is only half the battle — these are the resources I'd genuinely recommend for actually internalizing Linux internals and daily-driver skills:

← Back to Tech