Installing Linux and setting up your environment
In this series (15 parts)
- What is Linux and how it differs from other OSes
- Installing Linux and setting up your environment
- The Linux filesystem explained
- Users, groups, and permissions
- Essential command line tools
- Shell scripting fundamentals
- Processes and job control
- Standard I/O, pipes, and redirection
- The Linux networking stack
- Package management and software installation
- Disk management and filesystems
- Logs and system monitoring
- SSH and remote access
- Cron jobs and task scheduling
- Linux security basics for sysadmins
Getting Linux running on your machine takes about 30 minutes. You need a USB drive, an ISO image, and a basic understanding of disk partitioning. This article walks through the entire process from choosing a distro to running your first commands after boot.
Prerequisites
You should read What is Linux and how it differs from other OSes first to understand what distributions are and why they exist.
Choosing a distribution
For your first install, pick one of these three:
Ubuntu if you want the smoothest experience. It has the largest community, the most tutorials, and hardware support that works out of the box 95% of the time. Use the LTS version (currently 24.04) for stability.
Debian if you want something rock-solid and minimal. Slightly harder to set up than Ubuntu, but you will learn more in the process. Good if you plan to run servers.
Fedora if you want newer software packages. Uses dnf instead of apt. Good choice if you are coming from a Red Hat or CentOS background.
For this walkthrough, we will use Ubuntu 24.04 LTS. The concepts apply to any distro.
Step 1: Download the ISO
Go to the official Ubuntu website and download the desktop ISO. Verify the download with a checksum:
# On your current OS, after downloading
sha256sum ubuntu-24.04-desktop-amd64.iso
Output:
a3b5d1e2f4c6... ubuntu-24.04-desktop-amd64.iso
Compare this hash to the one listed on Ubuntu’s download page. If they match, your download is intact. If they do not match, download again. A corrupted ISO will cause installation failures that are hard to diagnose.
Step 2: Create a bootable USB
You need a USB drive with at least 4GB. All data on it will be erased.
On Linux or macOS:
# Find your USB drive
lsblk
Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 500G 0 disk
sdb 8:16 1 16G 0 disk # <-- this is the USB
# Write the ISO to the USB drive (replace /dev/sdb with your device)
sudo dd if=ubuntu-24.04-desktop-amd64.iso of=/dev/sdb bs=4M status=progress
sync
Output:
3456789504 bytes (3.5 GB, 3.2 GiB) copied, 120 s, 28.8 MB/s
⚠ Double-check the device name. Writing to the wrong device will destroy data on that disk.
On Windows:
Use Rufus or balenaEtcher. Select the ISO, select your USB drive, click Start.
Step 3: Boot from USB
- Insert the USB drive into the target computer
- Restart and enter the BIOS/UEFI menu (usually F2, F12, Del, or Esc during boot)
- Change the boot order to boot from USB first, or select the USB from the boot menu
- Save and exit BIOS
The Ubuntu installer will load. Choose “Try or Install Ubuntu.”
Step 4: Partitioning
This is where most beginners get nervous. For a dedicated Linux machine, the automatic partitioning is fine. For a dual-boot setup with Windows, you need to understand what partitions are.
graph LR A[Physical Disk 500GB] --> B[EFI Partition 512MB] A --> C[Root Partition / 450GB] A --> D[Swap Partition 16GB] style B fill:#81c784,stroke:#388e3c,color:#000 style C fill:#64b5f6,stroke:#1976d2,color:#000 style D fill:#ffb74d,stroke:#f57c00,color:#000
Recommended partition layout for a single Linux install:
| Partition | Mount Point | Size | Filesystem | Purpose |
|---|---|---|---|---|
| EFI | /boot/efi | 512 MB | FAT32 | Bootloader |
| Root | / | Rest of disk minus swap | ext4 | Everything else |
| Swap | (none) | 1x to 2x RAM | swap | Virtual memory, hibernation |
For manual partitioning in the installer:
- Select the target disk
- Create a new partition table (GPT for UEFI systems)
- Create the EFI partition first (512 MB, FAT32, mount at /boot/efi)
- Create the swap partition (match your RAM size)
- Create the root partition (use all remaining space, ext4, mount at /)
If you want a separate /home partition (useful for reinstalling the OS without losing personal files), take some space from root:
| Partition | Size |
|---|---|
| / | 50-100 GB |
| /home | Remaining space |
Step 5: Complete the installation
The installer will ask for:
- Your name, computer name, username, and password
- Timezone
- Whether to install third-party drivers (say yes)
Click Install and wait. This takes 10-20 minutes depending on your disk speed. When done, reboot and remove the USB drive.
Step 6: First boot and initial setup
After reboot, log in with your credentials. Open a terminal (Ctrl+Alt+T on Ubuntu) and update your system:
sudo apt update && sudo apt upgrade -y
Output:
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Get:2 http://archive.ubuntu.com/ubuntu noble-updates InRelease [89.7 kB]
...
Reading package lists... Done
Building dependency tree... Done
Calculating upgrade... Done
The following packages will be upgraded:
base-files libc6 ...
14 upgraded, 0 newly installed, 0 to remove and 0 not to upgrade.
This does two things:
apt updaterefreshes the list of available packagesapt upgradeinstalls newer versions of packages you already have
Package managers: apt, dnf, pacman
The package manager is how you install, update, and remove software. Each distro family has its own.
apt (Debian/Ubuntu)
# Search for a package
apt search neovim
# Install a package
sudo apt install neovim
# Remove a package
sudo apt remove neovim
# Remove a package and its config files
sudo apt purge neovim
# List installed packages
apt list --installed | head -20
dnf (Fedora/RHEL)
# Search for a package
dnf search neovim
# Install a package
sudo dnf install neovim
# Remove a package
sudo dnf remove neovim
# List installed packages
dnf list installed | head -20
pacman (Arch Linux)
# Search for a package
pacman -Ss neovim
# Install a package
sudo pacman -S neovim
# Remove a package and unused dependencies
sudo pacman -Rs neovim
# List installed packages
pacman -Q | head -20
Example 1: Install and configure a development environment
Let’s set up a basic development environment on Ubuntu. This installs Git, a code editor, a C compiler, Python, and common build tools:
sudo apt install -y git curl wget build-essential python3 python3-pip neovim
Output:
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
build-essential g++ gcc git make neovim python3-pip ...
0 upgraded, 23 newly installed, 0 to remove and 0 not to upgrade.
Need to get 45.2 MB of archives.
...
Setting up build-essential (12.10ubuntu1) ...
Verify the installations:
git --version
python3 --version
gcc --version | head -1
nvim --version | head -1
Output:
git version 2.43.0
Python 3.12.3
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
NVIM v0.9.5
Configure Git with your identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
git config --global init.defaultBranch main
Example 2: Install Docker on Ubuntu
Docker is essential for modern development. Here is the complete installation from the official Docker repository:
# Remove any old Docker packages
sudo apt remove -y docker docker-engine docker.io containerd runc 2>/dev/null
# Install prerequisites
sudo apt install -y ca-certificates curl gnupg
# Add Docker's official GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Add your user to the docker group so you do not need sudo for every Docker command:
sudo usermod -aG docker $USER
Log out and back in for the group change to take effect. Then verify:
docker run hello-world
Output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
What comes next
Now that you have a running Linux system, the next article covers The Linux filesystem explained, which teaches you where everything lives on the disk and why.
For a deeper dive into package management including building from source and managing repositories, see article 10 in this series.