Guides ยท Oct 15, 2026
Ubuntu Automatic Security Updates: Set Up unattended-upgrades
Turn on automatic security updates on an Ubuntu VPS with unattended-upgrades: install, configure, reboot behavior, dry run and logs.
Most compromises of small servers come from software that was never updated. Ubuntu can install security updates for you in the background using a package called unattended-upgrades. On an Ubuntu VPS this takes about two minutes and is one of the best things you can do for safety. This guide works on Ubuntu 22.04, 24.04 and 26.04.
1. Install and enable it
sudo apt update
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
Choose Yes when asked whether to download and install stable updates automatically. On many Ubuntu images the package is already installed; running the commands again is harmless.
2. Check what it will update
cat /etc/apt/apt.conf.d/20auto-upgrades
You should see:
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
The package lists refresh every day and security updates are installed daily. By default it only installs updates from the Ubuntu security pocket (and ESM security if enabled), not every package, which keeps the risk of breaking changes low. You can see the allowed sources in /etc/apt/apt.conf.d/50unattended-upgrades.
3. Decide about automatic reboots
Some updates, such as the kernel, only take effect after a reboot. Unattended-upgrades can reboot for you at a quiet hour. Edit the file:
sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
Find and change these lines (remove the leading //):
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
Only enable this if your services start by themselves after boot. Services managed with systemd or PM2 (see PM2 vs systemd) do. If you run a game server or a service you must restart by hand, leave automatic reboot off and reboot on your own schedule. The file /var/run/reboot-required exists when a restart is pending.
4. Test with a dry run
sudo unattended-upgrade --dry-run --debug
This shows which packages would be upgraded without changing anything. Look for lines saying which origins are allowed and "No packages found that can be upgraded unattended" if the system is up to date.
5. Read the logs
sudo less /var/log/unattended-upgrades/unattended-upgrades.log
systemctl list-timers apt-daily*
The log lists every package that was installed automatically, and the timers show when the next run is scheduled.
What it does not do
- It does not upgrade to a new Ubuntu release. For that, follow upgrading Ubuntu 24.04 to 26.04.
- It does not update software you installed outside apt, such as Docker images, npm packages, Python environments or apps you built from source. Update those yourself.
- It does not replace a firewall, SSH keys or backups. Combine it with our secure Ubuntu VPS checklist.
Frequently asked questions
Is it safe to enable automatic updates on a server?
Security-only updates are generally low risk and are widely recommended. Keep backups, and think carefully before enabling automatic reboots if your services do not restart on their own.
How do I check if unattended-upgrades is working?
Run sudo unattended-upgrade --dry-run --debug and read /var/log/unattended-upgrades/unattended-upgrades.log.
Does it update everything?
By default it installs security updates only. Other packages, Docker images and apps you installed yourself need manual updates.
Will it reboot my server?
Only if you enable Automatic-Reboot in 50unattended-upgrades. Otherwise a reboot-required file is created and you reboot when ready.
Related guides
- How to Secure a New Ubuntu VPS (First 10 Minutes)
- How to Secure SSH on a New VPS: Keys, Config and Fail2ban
- Ubuntu 26.04 VPS Setup and Hardening Checklist
Need a server for this?
Every TidalVPS VPS comes with full root access, unmetered traffic, daily backups and DDoS protection.