Skip to content

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.

Unlike consumer operating systems, a Linux server installation is heavily focused on disk layout, network configuration, and security right from the start.

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.

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.

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.

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.

During or immediately after installation, you must configure the identity and networking of the server.

You should rarely use the root account for daily tasks. Create a standard user and assign it sudo privileges.

Terminal window
# Add a new user
useradd -m -s /bin/bash sysadmin
# Set a password
passwd 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 sysadmin

The hostname identifies the machine on the network.

Terminal window
# View the current hostname
hostnamectl
# Set a new hostname
hostnamectl set-hostname web-server-01

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, or enp0s3.
  • Configuration is usually handled by Netplan (Ubuntu) or NetworkManager (RHEL/CentOS).

Once the OS is running, the first steps are always updating the system and securing access.

Linux relies on repositories (remote servers hosting software packages) for installations and updates.

Terminal window
# On Debian/Ubuntu (APT)
# Update the local list of available packages
sudo apt update
# Upgrade installed packages to their latest versions
sudo apt upgrade -y
# On RHEL/AlmaLinux (DNF/YUM)
sudo dnf update -y

Secure Shell (SSH) allows you to manage the server remotely.

Terminal window
# Install the SSH server (if not already installed)
sudo apt install openssh-server -y
# Check its status
sudo systemctl status ssh

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 login
PermitRootLogin no
# Disable password authentication (force SSH Keys only)
PasswordAuthentication no
# Change the default SSH port (optional but reduces log spam)
Port 2222

After editing, restart the service: sudo systemctl restart ssh.

2. Setup a Basic Firewall Use UFW (Uncomplicated Firewall) on Ubuntu or Firewalld on RHEL.

Terminal window
# Allow only essential traffic (e.g., SSH, HTTP, HTTPS)
sudo ufw allow 22/tcp # Or your custom SSH port
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
# Enable the firewall
sudo ufw enable
# Check status
sudo ufw status