Skip to main content

Update & Restart Server

Update & Restart Server

When setting up a brand-new Ubuntu server, one of the first things we should do is update the system and restart it before installing additional software.

A. Update the Package List

Ubuntu uses APT (Advanced Package Tool) as its package manager.

apt update

apt update fetches the latest information about available packages and their versions.

It does not actually upgrade the installed packages.

B. Upgrade Installed Packages

After updating the package list, upgrade the packages already installed on the system.

apt upgrade

This checks the packages and libraries installed on the current operating system and brings them up to their latest available versions.

It is better to update the system before installing additional software, because upgrading later could introduce breaking changes.

The basic order is:

C. Handle Upgrade Prompts

During apt upgrade, Ubuntu may display additional prompts.

Configuration Files

You may see a prompt saying that a newer version of a configuration file is available.

If the existing local version is already working, we can choose to keep the currently installed local version instead of replacing it.

Pending Kernel Upgrade

You may also see:

Pending kernel upgrade

The kernel is a low-level part of the operating system that communicates with the hardware.

A kernel update may therefore require a system restart before the new version is fully used.

Restart Services

Ubuntu may also ask which services should be restarted after the upgrade.

In this case, the default selections are usually sufficient.

If the interface is difficult to navigate, use Tab to move to the OK button.

D. Restart the Server

Once the upgrades have completed successfully, restart the server.

shutdown now -r

The command can be broken down as:

  • shutdown → shut down the system
  • now → perform the shutdown immediately
  • -r → restart the system after shutting down

Therefore:

shutdown now -r
│ │
│ └── Restart after shutdown
└─────── Shut down immediately

E. Why Specify now?

When using shutdown, we need to specify when the shutdown should happen.

For this setup, we want the server to restart immediately, so we use:

shutdown now -r

Restarting a production server is not something we normally want to do unexpectedly, which is why shutdown commands support scheduling.

F. SSH Disconnects During Reboot

Once the restart begins, the current SSH connection will be terminated.

This is expected because the server temporarily goes offline while rebooting.

It may take a few seconds before the server becomes available again.

G. Reconnect to the Server

After waiting for the reboot to finish, try connecting again with SSH.

ssh root@<server-ip>

If SSH initially fails, the server may simply still be coming back online.

Wait a little longer and try again.

H. If You Forget -r

If you accidentally shut down the server without restarting it, the server can still be managed through the DigitalOcean control panel.

From there, you can bring the server back up or shut it down.

However, whenever possible, server administration should be performed through the command line.

I. Complete Flow

The complete update and restart process is:

Key Takeaway

For a new Ubuntu server, update the existing system before installing additional software:

apt update
apt upgrade
shutdown now -r

apt update refreshes the available package information, while apt upgrade upgrades the packages already installed on the system.

After the upgrade, rebooting ensures that system-level updates, including kernel updates when applicable, can take effect.

Once the server is back online, reconnect through SSH and continue with the next stage of server configuration.