Update Ubuntu and Debian server packages safely
By the end: You will have reviewed the proposed changes, applied suitable updates and checked access and applications. A package is installed software or one of its components.
Current packages help address known vulnerabilities and software defects. However, updating a web server, database or SSH package can affect running services. This guide covers controlled package updates within the current operating system release.
Applies to: Ubuntu 24.04 LTS and Debian 13 using APT, with a sudo-enabled account. It does not cover distribution release upgrades, changing the selected kernel family, or updating components managed by a control panel such as cPanel. If you use a control panel, first follow its vendor's supported update procedure.
The screenshots show actual terminal output from a DCHost demo server running Ubuntu 24.04. Package counts and versions change over time; do not expect identical numbers on your server. If you are signed in as root, the sudo prefix is unnecessary.
Check each result before moving to the next step.
- Backup and maintenance
Prepare recovery, disk space, a maintenance time and recovery access.
- Review the plan
Refresh package information; preview changes with apt -s upgrade.
- Apply the update
If the plan is suitable, run apt upgrade and read confirmation and configuration prompts.
- Check again
Test a new SSH connection, services and the application's essential operations.
Package updates can restart services; choose a suitable maintenance window in advance.
1. Prepare maintenance and recovery
Complete four preparations before starting:
- Prepare a current backup you can restore.
- Confirm there is enough disk space.
- Choose a maintenance time suitable for affected customers.
- Verify a second SSH connection and a recovery method.
Not ready? Complete the missing preparation before running the update.
Check your application's supported versions and any third-party package repositories. Prepare a current backup and a tested restore path. Use the resource checks to confirm sufficient disk space. Choose a maintenance window because services may restart during updates.
If preparation shows No space left on device or high inode usage, first identify what is filling the filesystem. Confirm enough space to download and unpack packages before starting updates; do not delete package-manager records to make room.
Keep your SSH session open and verify a second connection. Before a possible reboot, establish the console or recovery method actually available for your service. If you do not have working recovery access, plan changes that affect connectivity with your administrator or support.
If your service includes snapshots, you can create a copy before updating through server management. Wait for creation to finish and the snapshot to appear ready in the list. Creating a snapshot does not prove that restoration has been tested or that it contains a consistent database backup; prepare your application backup separately.
The actual snapshot record after creation completed. The name is hidden.


Step 1: Check that the record exists
- Check that the record exists
Compare Total Snapshots in Snapshot Statistics with the record below. Clicking Create Snapshot alone is not enough.
What you should see: One snapshot is listed in this example.
- Read the date and status
The record should predate the update. The Current badge on this screen identifies the snapshot's current status.
What you should see: A dated record and the Current badge are visible.
- Check whether memory is included
Not Included under Memory State means running memory is not part of this snapshot. Prepare application and database backups separately.
The snapshot was created; Restore was not used. Creating a snapshot does not mean restoration was tested. Slot availability depends on your service.
2. Refresh package information and review changes
Where? On the server, through SSH. Run each line in order. If one fails, resolve it before the next line.
| Command | What it does | Expected result |
|---|---|---|
sudo apt update | Refreshes repository package information | Lists download without errors; software is not yet upgraded |
apt list --upgradable | Lists available package updates | Package/version list, or no packages to upgrade |
sudo apt -s upgrade | Previews the update without applying it | Summary of proposed changes |
sudo requests administrator privileges; -s means simulation. A repository is a source from which packages are downloaded.
Run these commands on the server. The first refreshes package information without yet upgrading installed software:
sudo apt update
apt list --upgradable
sudo apt -s upgrade
apt -s upgrade simulates the operation. Review new packages, components to be updated and the proposed changes. Resolve repository, signature or network errors from apt update before proceeding; do not disable signature verification.
If you see Temporary failure resolving, Could not resolve host or Network is unreachable, use the Linux internet and DNS guide to identify the failing stage. Verify repository access before continuing the update; disabling repository signature checks does not fix DNS.
Simulation does not test application compatibility. In particular, compare third-party database and runtime packages with your application's support requirements. For critical production systems, test in a comparable non-production environment first.
apt update refreshes repository information. Installed software has not been upgraded yet.


Step 1: Run the command on the server
- Run the command on the server
Run sudo apt update in your server's SSH session. This line shows the command used in the recording.
- Read the result
Package-list processing finished with Done and 120 upgradable packages were reported. Your count may differ; these packages have not been installed yet.
What you should see: Package information is current; the update plan can now be reviewed.
Resolve download, repository or signature errors before upgrading. Three of the 120 updates shown here were later deferred due to phased delivery.
Refreshing package information does not install the updates. In this example, the first screen reported 120 upgradable packages; the installation plan deferred three of them due to phased delivery.
Read the summary as follows:
| On-screen phrase | Meaning |
|---|---|
upgraded | Installed packages that will move to newer versions |
newly installed | New packages needed for the update |
to remove | Packages scheduled for removal; do not approve unexpected removals |
not upgraded | Packages not updated in this operation; investigate why |
Need to get | Total size of files to download |
The demo server's plan showed 117 upgrades, 2 new packages, 0 removals and 3 packages not upgraded. APT explicitly identified the three packages as deferred due to phasing, meaning Ubuntu was distributing those updates in stages. We did not force their installation.
3. Run the update interactively
This step changes software on the server. Run it only after preparing the backup and reviewing the plan. Read the confirmation summary; stop before agreeing if changes are unexpected.
If preparation and the simulation are satisfactory:
sudo apt upgrade
This frame was captured from the actual apt upgrade operation before y was entered.


Step 1: Compare the package counts
- Compare the package counts
Compare 117 upgraded, 2 newly installed, 0 to remove and 3 not upgraded with the reviewed plan. Do not approve unexpected changes.
- Check download and disk requirements
This example downloads 81.6 MB and needs about 6.8 MB of additional disk space. Confirm the required space is available on your server.
- Enter y if the plan is suitable
At Do you want to continue? [Y/n], type y and press Enter. Type n and press Enter to cancel. After confirming, wait until installation finishes.
This is a confirmation screen, not evidence that installation finished. The phasing line explains the three deferred packages; the suggested autoremove command was not run.
- Review the list for unexpected packages, removals or disk requirements.
- At
Do you want to continue? [Y/n], type y and press Enter if the plan is suitable. To cancel, type n and press Enter. - Wait for downloading and installation to finish.
Unpackingmeans package files are being extracted;Setting upmeans the package is being configured. - Read any additional prompt before answering. Do not close the window or reboot the server while the operation is running.
Compare the confirmation summary with the changes you expect. Leaving out -y allows you to review package manager prompts. If asked to replace a configuration file, inspect the differences between your settings and the new version instead of blindly replacing everything.
apt upgrade can hold back an update if it requires removing installed packages. Do not immediately run full-upgrade for remaining updates; review its new plan, including removals, separately. autoremove removes dependencies considered no longer required; it does not upgrade held-back packages. Review its removal list separately too. An operating system release upgrade needs its own migration plan.
4. Check the result and running services
Check on the server. Run these commands in order, then test the application too.
| Check | What should you see? |
|---|---|
apt list --upgradable | Remaining updates; investigate why any remain |
systemctl --failed --no-pager | Failed units; investigate any reported errors |
uname -r | The kernel version currently running |
sudo dpkg --audit | No incomplete package installation problems; normally produces no output |
The kernel is the operating system's core. Installing a new kernel package does not mean that version is already running.
apt list --upgradable
systemctl --failed --no-pager
uname -r
sudo dpkg --audit
Confirm that the package operation completed without errors. Investigate remaining updates: phased delivery, held packages or dependencies may be involved. Even if systemctl --failed lists nothing, test the web service, database and application flows. Open a fresh SSH connection; a surviving old session does not prove that new connections work.
On Ubuntu, /var/run/reboot-required may indicate that a reboot is needed. Its absence is not definitive on every system. Follow package notifications and distribution guidance. If a reboot is required, wait until the maintenance window, package operations are complete and recovery is ready. Afterwards, verify the running kernel, SSH access and application again.
5. Reboot if needed and connect again
On Ubuntu, check the reboot indicator with:
if test -f /var/run/reboot-required; then
cat /var/run/reboot-required
else
printf 'Reboot required: no\n'
fi
If you see *** System restart required ***, review your maintenance preparation. Once package operations are complete, fresh SSH access works and recovery is ready, run this during the planned maintenance window:
sudo reboot
This restarts the server and may disconnect the current SSH session. After allowing time for startup, open a new SSH connection from your computer. An old terminal remaining open is not sufficient. After reconnecting, run:
uname -r
systemctl is-active ssh
systemctl --failed --no-pager
sudo dpkg --audit
apt list --upgradable
This output comes from a new SSH connection opened after the reboot.


Step 1: Check the running kernel and SSH
- Check the running kernel and SSH
uname -r now reports 6.8.0-147-generic. The active line below shows SSH is running. Establishing this new session also confirms a fresh connection works.
- Check for failed units
0 loaded units listed under systemctl --failed means no failed units were found in this check. Test your application separately as well.
- Read remaining updates and reboot status
Three updates remain because of phased delivery. Reboot required: no means the reboot indicator was absent during this check.
What you should see: Package installation completed and SSH access works on the newer kernel.
No control panel or customer application was installed in this example. This screen does not establish that your own website or database is working.
In the fresh SSH connection, the demo server was verified to be running kernel 6.8.0-147-generic, with SSH active and 0 failed units. The reboot-required indicator was gone. Comparing package inventories confirmed 117 version changes, 2 new packages and no package removals. These results apply to the demo server. Test your own website, database and application separately.
After completion:
- Open a new SSH connection from a separate window on your computer.
- Check the website and the application's essential operation.
- Verify the relevant database and services.
- Record the result and time.
Actual terminal recording
Recorded on an actual demo server. Long waits are shortened while the operation order is preserved. Rebooting and fresh SSH verification are shown in the separate step above.
Video transcript
apt upgraderuns on the demo server. The recorded user isroot, so the command does not need asudoprefix.- APT shows 117 packages to upgrade, 2 new packages and no removals. The download size is 81.6 MB; 3 updates are deferred due to phased delivery.
- After the plan is reviewed,
yis entered and Enter is pressed. Packages are downloaded, unpacked and configured. - Services restart during installation. The final check reports that the server needs to restart to use the newer kernel.
- The package operation completes with exit code
0. Rebooting happens as a separate operation outside this recording, followed by verification in a fresh SSH connection.
No configuration-file replacement prompt appeared in this recording. If one appears on your server, review the differences between the old and new settings before answering.
If an update reports Killed, check OOM records and available memory before immediately retrying. Identify which process stopped, when and why; exit code 137 alone does not establish memory exhaustion.
If CPU usage rises during an update, check the process and load measurements to see whether package unpacking or configuration is progressing normally. Do not terminate APT or dpkg solely because of a high percentage; inspect progress and resource use during the same interval.
Common errors and recovery
An APT lock error may mean another package operation or automatic update is running. Do not delete lock files or arbitrarily kill package manager processes; identify the active operation and allow it to finish. If disk space runs out, perform the disk checks instead of deleting large files at random.
There is no single general-purpose command that safely undoes every failed update. Inspect package logs, service errors and the current data state, then follow your application or system restore plan. Before reverting to an earlier copy, decide how to preserve records created since that copy.
Automatic update behavior depends on the image and configuration. Do not assume it is enabled. Check allowed repositories, notifications and reboot policy separately.
Why do packages remain after a completed update?
If APT says deferred due to phasing, Ubuntu is gradually making that update available to machines. In this example, apparmor, libapparmor1 and open-vm-tools were deferred for this reason. Do not disable phased delivery simply to empty the list. For packages kept back for other reasons, use apt-mark showhold to inspect explicit holds and apt-cache policy PACKAGE_NAME to inspect the candidate version; replace PACKAGE_NAME with the actual name in the list.
Does updating Ubuntu 24.04 move me to a different release?
The apt upgrade operation in this guide updates packages from the existing Ubuntu 24.04 repositories. Moving from 24.04 to another Ubuntu release needs a separate compatibility and migration plan. Do not change repository release names arbitrarily.