Managing Linux Updates

When you run your own servers one of your most critical responsibilities as the server owner is making sure the software stack is up to date on all security fixes.

In WPCloudDeploy you can quickly view the number of pending updates in your server list – you just need to look at the health column (usually the last column in your server list screen):

Here is how you can read the image above:

  • Non Sec. Updates mean that there are updates that are not security related and that there are no additional security updates needed for the server. Running updates for the server would be completely optional in this instance.
  • Sec Updates x of n (on the dark red background) mean that there are security updates needed but only ‘x’ updates are security updates and ‘n’ is the total number of updates (security and non-security related.)

WPCloudDeploy servers configure the Linux UNATTENDED UPGRADES function to ensure that security updates are applied every evening.

Handling “Stuck” Updates

There might be times where the updates fail to run. You can detect this if you see the security updates message ‘stuck’ on a server over multiple days or if there is an abnormally large number of security updates pending (such as you see in the image above where some servers show more than 100 security updates pending).

When this happens, you have three choices:

  • Restart the server – sometimes this will remove a lock from a failed update. You will have to wait up to 24 hours to see if the message in the health column shows a reduced number of security updates.
  • If restarting does not work then you can attempt to forcibly run updates using the options on the UPGRADES tab for each server. If updates are successful, the health column should eventually update with new data.
  • If neither of the above options work, then your only choice is to login via SSH and run the updates from the command line. You should restart the server first before running updates just to make sure that any miscreant file locks are cleared.

After you login, you need to run two commands. The first is this:

sudo apt-get update -y

Running it will refresh the data stored in your local software repositories. It is important that this be up to date before running upgrades using the following command:

sudo apt-get upgrade -y

You might see prompts asking whether to overwrite or keep existing configuration files:

You should always choose the option to keep the existing configuration files (which is usually the default option).

Handling DPKG Errors

Sometimes, when you try to run the apt-get commands, you might see an error such as:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

Usually, you just have to do what the error says – execute the following:

sudo dpkg --configure -a

and follow any on-screen instructions.

See Also: Handling dpkg messages in your SSH Logs

After Update Tasks

After all updates are complete you should restart the server. You can do that from the server POWER tab or from the command line as follows:

sudo reboot

After rebooting, please double-check the version of PHP that is used on the command line:

sudo php --version

It should be PHP 7.4, 8.0 or, if you’re absolutely sure about your plugin & theme compatibility, 8.1. You can change the version in the server TOOLS tab (under the SET SERVER PHP CLI VERSION section)

Note that on some older servers, a small number of security updates might always remain unapplied. This generally occurs on Ubuntu 18.04 LTS and 20.04 LTS servers. If you have these servers you should create a new server running Ubuntu 22.04 LTS and move your sites to them – Ubuntu 18.04 servers stopped receiving security updates in April 2023 and Ubuntu 20.04 will no longer receive security updates after April 2025 (unless you have purchased an extended support package from Canonical.)

Finally, if you see a ‘Restart Needed’ message in your server list health column you should restart the server. Otherwise, future security updates might not be applied.

Learn more about apt-get – the Ubuntu utility that manages software installs and updates for you Ubuntu servers.

Was This Article Useful? Or do you have questions or comments about it (or our products & services)? We'd love to hear from you!

Please enter your name.
Please enter a message.
You must accept the Terms and Conditions.
Please check the captcha to verify you are not a robot.

Automatic Notification Of New Articles

Sign up to get automatic notifications of new articles.  This is a different list than our standard list - you only get new articles once a week (usually on Mondays).  No other emails will be sent unless you sign up for our general list as well.

Posted in ,