Marcio Cunha

How to Install Ubuntu Server and Prepare the System for Production

Learn how to install Ubuntu Server from scratch and apply essential security, networking, and management configurations to run real applications in production environments.

Marcio Cunha12 min
Also available in:EspañolPortuguês
Summary
  • Choosing the correct LTS version ensures long-term support and critical operational stability for enterprise environments.
  • Proper disk partitioning isolates critical data from the operating system, preventing corruption from storage exhaustion.
  • Configuring SSH keys replaces vulnerable passwords with high-strength asymmetric cryptography against intrusions.
  • Adjusting automatic update policies keeps the system secure without compromising the stability of running services.
  • Implementing efficient firewalls blocks unnecessary ports and restricts the attack perimeter before launch.

Planning and Base Installation of Ubuntu Server

Installing an operating system intended for servers requires decisions that directly impact infrastructure stability and security. Ubuntu Server, distributed by Canonical, is one of the market's most popular choices due to its massive community, vast documentation, and long-term support. The first practical step involves obtaining the official ISO image of the LTS version, which means Long Term Support, guaranteeing security updates and bug fixes for five years. This stability is critical to prevent unexpected updates from breaking mission-critical systems in production.

During the installation process via bootable USB media, the guided installer offers crucial steps such as keyboard layout selection, network configuration, and access credential definition. An important decision in this phase is disk partitioning configuration. In production environments, utilizing LVM (Logical Volume Manager), a manager that simplifies partition manipulation at runtime, allows resizing logical volumes without shutting down the machine. It is highly recommended to separate the root directory from data or database folders, ensuring that a storage overflow in logs does not corrupt the operating system.

Upon finishing the basic installation, the system reboots and presents an austere command line interface without complex visual elements. This resource economy is intentional: servers do not need to spend RAM or processing power rendering unnecessary graphics. All administration is performed remotely through the terminal, which requires rigorous planning of network security within the first minutes of operation.

Network Configuration and Secure Remote Access

With the server operational, the next step involves establishing a stable network configuration shielded against malicious access. Servers require static IP addresses or rigorous DHCP reservations so that dependent applications know exactly where to find them. In modern Ubuntu Server, network management is handled by Netplan, a tool that uses YAML-based configuration files to define network interfaces simply and standardly.

To administer this machine remotely, the SSH (Secure Shell) protocol is widely used, creating an encrypted channel between the administrator's computer and the server. However, leaving the default SSH port open to the internet without additional protection is an invitation for brute-force attacks, where bots ceaselessly attempt to guess passwords. The first defense barrier consists of disabling password login and requiring cryptographic key-based authentication using RSA or Ed25519, where only authorized computers hold the corresponding private key.

Furthermore, changing the default communication port and installing tools like Fail2ban, a utility that monitors access logs and temporarily blocks IP addresses with suspicious behavior, drastically raises perimeter security. These practices transform an exposed server into a digital fortress, reducing the risk of automated intrusions exploiting weak credentials or default configurations.

System Hardening with Firewall and Updates

Protecting the operating system against unwanted traffic is a step that cannot be neglected. Ubuntu Server includes UFW (Uncomplicated Firewall), a simplified interface for iptables that allows managing network packet filtering rules with intuitive commands. In a production environment, the default policy must be to block all incoming traffic and allow only what is strictly necessary, such as ports corresponding to HTTP and HTTPS web traffic, in addition to the modified SSH port.

Another essential pillar of production preparation is the software update strategy. Security vulnerabilities are constantly discovered in complex systems, and applying fixes rapidly is the only way to mitigate exploitation risks. The 'unattended-upgrades' package can be configured to apply security updates automatically in the background, preventing the administrator from having to intervene manually in critical kernel patches or foundational libraries.

However, complete automatic updates that alter large packages can introduce unexpected behaviors in sensitive applications. Therefore, the best practice in production consists of strictly automating security patches and reserving major updates for scheduled maintenance windows, where the team can validate application functionality after changes are applied.

Resource Monitoring and Initial Observability

A production server must not operate as a black box; continuous metrics on physical resource consumption must be collected. Native tools like 'htop', 'iotop', and 'df' offer instant diagnostics of CPU usage, RAM, disk activity, and available space. However, for enterprise environments, historical visibility is indispensable to predict bottlenecks before they cause service unavailability.

Installing lightweight monitoring agents, such as Prometheus Node Exporter or tools integrated into observability platforms, allows tracking usage trends over time. When memory usage reaches critical levels or disk space gradually exhausts, automated alerts prevent catastrophic failures from occurring without prior notice, allowing surgical and planned interventions.

Beyond hardware metrics, centralized log tracking through tools like systemd journald ensures application errors are tracked with precision. The discipline of regularly auditing logs separates amateur professional environments from resilient infrastructures capable of sustaining complex commercial operations.

Final Considerations for Production Environments

Preparing Ubuntu Server for production is a continuous exercise of technical rigor, architectural planning, and disciplined automation. From choosing the correct LTS version to the rigorous configuration of networks, SSH keys, and firewalls, every decision builds a defense layer that protects data and ensures high application availability. The apparent simplicity of the command line interface hides a robust ecosystem capable of sustaining extremely demanding workloads.

Maintaining operational discipline after initial deployment is the secret to long-term success. Periodic security audits, access policy reviews, and disaster recovery tests ensure that infrastructure remains resilient against technological unforeseen events. With the fundamentals established in this guide, engineers gain the necessary confidence to scale systems and deliver real value to end users.