Linux — Getting Started
Linux powers the vast majority of servers, cloud infrastructure, embedded devices, and developer workstations. Whether you are deploying a Next.js app to a VPS, debugging a Docker container, or automating workflows with shell scripts, Linux fluency is a core engineering skill.
This section covers the topics that working developers actually need: navigating the terminal, understanding the filesystem, managing permissions, installing software, controlling processes, configuring networks, writing Bash scripts, editing files in vim, and connecting to remote machines over SSH.
Linux is technically a kernel — the piece of software that manages hardware, processes, memory, and device drivers. A complete operating system built around the Linux kernel is called a distribution (or distro). Distributions bundle the kernel with a package manager, system utilities, libraries, and often a desktop environment.
| Distribution | Package Manager | Best For |
|---|---|---|
| Ubuntu | apt / snap | Beginners, cloud, WSL |
| Debian | apt | Stable servers |
| Fedora | dnf | Modern desktop, containers |
| Arch Linux | pacman | Power users, rolling release |
| Alpine | apk | Containers, minimal images |
| RHEL / Rocky | dnf / yum | Enterprise servers |
info
The terminal is a text-based interface to the operating system. You type commands, the shell interprets them, and the kernel executes them. The default shell on most Linux systems is bash, though zsh and fish are also popular.
| 1 | # Print the current user and working directory |
| 2 | whoami |
| 3 | pwd |
| 4 | |
| 5 | # List files and directories |
| 6 | ls -la |
| 7 | |
| 8 | # Change directory |
| 9 | cd /var/log |
| 10 | |
| 11 | # Run a command with superuser privileges |
| 12 | sudo apt update |
| Command | What It Does |
|---|---|
| pwd | Print working directory |
| ls | List directory contents |
| cd | Change directory |
| mkdir | Create a directory |
| cp | Copy files or directories |
| mv | Move or rename files |
| rm | Remove files or directories |
| cat | Print file contents |
| less | View file contents interactively |
| man | Show manual page for a command |
Linux organizes files in a single hierarchical tree starting at the root directory /. The Filesystem Hierarchy Standard (FHS) defines the purpose of the top-level directories.
| 1 | / |
| 2 | ├── bin # Essential user binaries (ls, cp, mv) |
| 3 | ├── boot # Boot loader files and kernel |
| 4 | ├── dev # Device files (disks, terminals, etc.) |
| 5 | ├── etc # System-wide configuration files |
| 6 | ├── home # User home directories |
| 7 | ├── lib # Shared libraries and kernel modules |
| 8 | ├── media # Mount points for removable media |
| 9 | ├── mnt # Temporary mount points |
| 10 | ├── opt # Optional third-party software |
| 11 | ├── proc # Virtual filesystem for process/kernel info |
| 12 | ├── root # Home directory for the root user |
| 13 | ├── run # Runtime variable data |
| 14 | ├── sbin # System administration binaries |
| 15 | ├── srv # Service data |
| 16 | ├── sys # Virtual filesystem for system info |
| 17 | ├── tmp # Temporary files |
| 18 | ├── usr # User programs, libraries, docs |
| 19 | └── var # Variable data: logs, caches, mail |
best practice
Linux is a multi-user system. Every file and process is owned by a user and a group. Permissions are expressed as read (r), write (w), and execute (x) for the owner, group, and others.
| 1 | # View detailed file listing with permissions |
| 2 | ls -l /etc/passwd |
| 3 | # -rw-r--r-- 1 root root 2875 Jan 12 08:30 /etc/passwd |
| 4 | |
| 5 | # Change file permissions |
| 6 | chmod 755 script.sh |
| 7 | chmod u+x script.sh |
| 8 | |
| 9 | # Change file owner and group |
| 10 | sudo chown alice:developers project/ |
| 11 | |
| 12 | # Add a user to a group |
| 13 | sudo usermod -aG docker $USER |
| Numeric | Symbolic | Meaning |
|---|---|---|
| 700 | rwx------ | Owner only |
| 755 | rwxr-xr-x | Owner full, others read/execute |
| 644 | rw-r--r-- | Owner read/write, others read |
| 600 | rw------- | Owner read/write only |
Package managers install, update, and remove software while handling dependencies. The commands differ by distribution, but the concepts are the same.
| 1 | # Debian / Ubuntu |
| 2 | sudo apt update # Update package index |
| 3 | sudo apt upgrade # Upgrade installed packages |
| 4 | sudo apt install nginx # Install a package |
| 5 | sudo apt remove nginx # Remove a package |
| 6 | |
| 7 | # Fedora / RHEL / Rocky |
| 8 | sudo dnf update |
| 9 | sudo dnf install nginx |
| 10 | sudo dnf remove nginx |
| 11 | |
| 12 | # Arch Linux |
| 13 | sudo pacman -Syu # Update system |
| 14 | sudo pacman -S nginx # Install |
| 15 | sudo pacman -R nginx # Remove |
| 16 | |
| 17 | # Alpine (common in containers) |
| 18 | apk add nginx |
| 19 | apk del nginx |
Every running program on Linux is a process. The init system (usually systemd) manages background services that start automatically and keep running.
| 1 | # List running processes |
| 2 | ps aux |
| 3 | |
| 4 | # Interactive process viewer |
| 5 | htop |
| 6 | |
| 7 | # Start, stop, and inspect services |
| 8 | sudo systemctl status ssh |
| 9 | sudo systemctl start ssh |
| 10 | sudo systemctl enable ssh # Start on boot |
| 11 | sudo systemctl restart nginx |
| 12 | |
| 13 | # Send signals to processes |
| 14 | kill -TERM 1234 # Graceful stop |
| 15 | kill -9 1234 # Force kill |
| 16 | pkill node # Kill by process name |
Now that you understand the fundamentals, dive deeper into each topic: