NetPoa

Keep your Ubuntu server updated automatically

Updated 27 Nov 2026

Most hacked servers are running old software with known holes. Ubuntu can install security updates for you every day with unattended-upgrades. This guide sets it up, chooses a safe restart time and shows how to check it's working.

1. Install and turn it on

It's often installed already. Run this to make sure:

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

Answer Yes. This creates /etc/apt/apt.conf.d/20auto-upgrades. Check it:

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

It should contain:

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

"1" means every day.

2. Choose when to restart

Some updates, such as a new kernel, only take effect after a restart. By default the server never restarts by itself, so those fixes wait until you do it.

To let it restart at a quiet time, create your own settings file. Using a separate file keeps your choices safe when Ubuntu updates its own one.

sudo nano /etc/apt/apt.conf.d/52unattended-upgrades-local

Add:

Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "03:00";
Unattended-Upgrade::Remove-Unused-Dependencies "true";

Save with Ctrl+O, Enter, Ctrl+X.

The server only restarts when an update needs it. Make sure your apps start again by themselves after a restart (for example with systemctl enable or PM2's pm2 startup).

3. Set your time zone

The restart time uses the server's clock. Set it to Tanzanian time so 03:00 means 03:00 for you:

sudo timedatectl set-timezone Africa/Dar_es_Salaam
timedatectl

4. Test it

Do a dry run. It shows what would be installed without changing anything:

sudo unattended-upgrade --dry-run --debug

Look for lines about allowed origins that include security, and no errors at the end.

5. Check it later

See what was installed and when:

sudo tail -n 50 /var/log/unattended-upgrades/unattended-upgrades.log

Check whether a restart is waiting:

ls /var/run/reboot-required

If the file exists, a restart is needed. If you didn't turn on automatic restarts, run sudo reboot at a quiet time.

What it updates

By default, only security updates from Ubuntu are installed automatically. That's the safe choice: they fix holes without changing how your software behaves. Other updates still need you:

sudo apt update && sudo apt upgrade

Do this once a month, after a backup, and check your sites afterwards.

Software you installed outside Ubuntu's own packages (for example with npm, pip, Composer or a downloaded file) is not updated by unattended-upgrades. Keep those up to date yourself.


Need a server? Order a Cloud VPS and get root access within minutes. For help, open a ticket and choose Technical.

Was this helpful?