Why update?
A VPS is a private slice of a big computer. You look after it yourself. Old software can have holes that hackers use. Updates close those holes and also fix errors. Running them often is one of the best ways to stay safe.
Warning
An update can change how programs work. Some updates need a restart, which takes the site offline for a short time. Take a backup or snapshot before you start. A snapshot is a saved copy of your whole server at one moment.
Ubuntu or Debian
- Connect to your server with SSH:
ssh root@your-server-ip
- Refresh the list of available updates:
sudo apt update
This only checks what is new. It does not install anything.
- Install the updates:
sudo apt upgrade -y
This installs the new versions of the software you already have.
- Remove packages you no longer need:
sudo apt autoremove -y
CentOS, AlmaLinux or Rocky Linux
- Connect with SSH.
- Run the update:
sudo yum update -y
On newer versions, you can use sudo dnf update -y in the same way.
Tip: CentOS 7 is old, and it no longer gets updates. Newer systems use similar commands.
Check if a reboot is needed
On Ubuntu, this file appears when a restart is needed:
ls /var/run/reboot-required
If the file exists, restart at a quiet time with sudo reboot.
If you use a control panel
Panels like cPanel have their own update system. Update the panel and the operating system as that panel advises. Do not mix tools without reading the panel's notes.
Automatic security updates
On Ubuntu you can turn on automatic security updates:
sudo apt install unattended-upgrades -y
sudo dpkg-reconfigure unattended-upgrades
This installs the helper and starts the setup screen. Choose Yes.
Quick recap
- Back up or take a snapshot first.
- Ubuntu and Debian:
apt update, thenapt upgrade. - CentOS family:
yum updateordnf update. - Reboot if the system asks for it.
- Consider automatic security updates.