APTUpdatesUbuntu5 min read

Update the operating system

Keep your VPS up to date with the latest security patches and package updates on Ubuntu and Debian.


Keeping your VPS updated is essential for security and stability. This guide covers Ubuntu and Debian.

Step 1 — Update the package list

bash
sudo apt update

This downloads the latest information from configured repositories.

Step 2 — Install available updates

bash
sudo apt upgrade -y

The -y flag automatically confirms the installation.

Step 3 — Upgrade packages with new dependencies

bash
sudo apt full-upgrade -y

This command also installs or removes packages if necessary to resolve dependencies.

Step 4 — Clean obsolete packages

bash
sudo apt autoremove -y
sudo apt autoclean

Configure automatic security updates

To have security patches install automatically:

bash
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure -plow unattended-upgrades

Select "Yes" when asked to enable automatic updates.

Verify the configuration:

bash
cat /etc/apt/apt.conf.d/20auto-upgrades

You should see:

terminal
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

For AlmaLinux / Rocky Linux

If your VPS uses AlmaLinux:

bash
sudo dnf update -y
sudo dnf install dnf-automatic -y
sudo systemctl enable --now dnf-automatic-install.timer

Reboot if necessary

If the kernel was updated:

bash
sudo reboot

Reconnect via SSH after a few seconds. Verify the active kernel with uname -r.


Was this guide helpful?