02. Installation & Setup
Whether you are provisioning a virtual machine in the cloud, setting up a bare-metal server, or installing a local testing environment, understanding the Linux installation process and initial setup is critical.
02.1 Installing Linux Concepts
Section titled “02.1 Installing Linux Concepts”Unlike consumer operating systems, a Linux server installation is heavily focused on disk layout, network configuration, and security right from the start.
UEFI vs BIOS
Section titled “UEFI vs BIOS”When a machine powers on, it needs firmware to initialize hardware and hand off control to the operating system.
- BIOS (Basic Input/Output System): The legacy standard. Uses the MBR (Master Boot Record) partitioning scheme, which has a 2TB drive limit and supports only 4 primary partitions.
- UEFI (Unified Extensible Firmware Interface): The modern standard. It supports the GPT (GUID Partition Table) scheme, allowing for drives larger than 2TB and practically unlimited partitions. It also supports Secure Boot.
Bootloader
Section titled “Bootloader”The bootloader is a small program that loads the Linux kernel into memory.
- GRUB (GRand Unified Bootloader): The most common bootloader. It presents a menu to choose which OS or kernel version to boot and then hands control to the kernel.
02.2 Storage Preparation
Section titled “02.2 Storage Preparation”Partitioning
Section titled “Partitioning”Partitioning divides your physical disk into logical sections. A standard server layout often includes:
/(Root): The main partition containing the OS./boot: Contains the bootloader and kernel (often a small partition, 500MB - 1GB)./home: (Optional) Separating user data so if the OS needs a reinstall, user data is preserved./var: (Optional) Often separated on servers because logs and databases can grow rapidly and fill up the disk.
Swap acts as “virtual memory.” If your system runs out of physical RAM, it temporarily moves inactive pages of memory to the Swap space on the hard drive.
- While slower than RAM, Swap prevents the system from crashing (or triggering the OOM killer) during memory spikes.
- Often provisioned as a dedicated partition or a swap file.
Filesystem Selection
Section titled “Filesystem Selection”Once partitioned, the disk must be formatted with a filesystem.
- ext4 (Fourth Extended Filesystem): The battle-tested, default standard for most Linux distributions. Very stable and reliable.
- XFS: Highly scalable, excellent for large files and high-performance storage. Often the default in RHEL-based systems.
- Btrfs / ZFS: Advanced filesystems supporting built-in snapshots, pooling, and self-healing.
02.3 System Configuration
Section titled “02.3 System Configuration”During or immediately after installation, you must configure the identity and networking of the server.
Initial User Creation
Section titled “Initial User Creation”You should rarely use the root account for daily tasks. Create a standard user and assign it sudo privileges.
# Add a new useruseradd -m -s /bin/bash sysadmin
# Set a passwordpasswd sysadmin
# Add the user to the sudo group (Ubuntu/Debian)usermod -aG sudo sysadmin
# (On RHEL/CentOS, the group is usually 'wheel')usermod -aG wheel sysadminHostname
Section titled “Hostname”The hostname identifies the machine on the network.
# View the current hostnamehostnamectl
# Set a new hostnamehostnamectl set-hostname web-server-01Network Configuration
Section titled “Network Configuration”Servers should generally have static IP addresses so clients always know where to reach them.
- Modern network interfaces are often named logically like
eth0,ens33, orenp0s3. - Configuration is usually handled by
Netplan(Ubuntu) orNetworkManager(RHEL/CentOS).
02.4 Post-Installation Setup
Section titled “02.4 Post-Installation Setup”Once the OS is running, the first steps are always updating the system and securing access.
Package Repositories & System Updates
Section titled “Package Repositories & System Updates”Linux relies on repositories (remote servers hosting software packages) for installations and updates.
# On Debian/Ubuntu (APT)# Update the local list of available packagessudo apt update# Upgrade installed packages to their latest versionssudo apt upgrade -y
# On RHEL/AlmaLinux (DNF/YUM)sudo dnf update -ySSH Installation & Configuration
Section titled “SSH Installation & Configuration”Secure Shell (SSH) allows you to manage the server remotely.
# Install the SSH server (if not already installed)sudo apt install openssh-server -y
# Check its statussudo systemctl status sshInitial Server Hardening
Section titled “Initial Server Hardening”Out of the box, servers require immediate security tweaks to prevent automated attacks.
1. Configure SSH for Security
Edit the SSH configuration file (/etc/ssh/sshd_config):
# Disable root loginPermitRootLogin no
# Disable password authentication (force SSH Keys only)PasswordAuthentication no
# Change the default SSH port (optional but reduces log spam)Port 2222After editing, restart the service: sudo systemctl restart ssh.
2. Setup a Basic Firewall Use UFW (Uncomplicated Firewall) on Ubuntu or Firewalld on RHEL.
# Allow only essential traffic (e.g., SSH, HTTP, HTTPS)sudo ufw allow 22/tcp # Or your custom SSH portsudo ufw allow 80/tcpsudo ufw allow 443/tcp
# Enable the firewallsudo ufw enable
# Check statussudo ufw status