How to Update Ubuntu via SSH: A Beginner's Guide

Learn to safely and efficiently update your Ubuntu server using simple SSH commands. This guide is perfect for beginners and includes additional steps for updating PHP, Nginx, and Bind9 via the Sury repository.

Preliminary Steps

Before diving into the update process, ensure you have SSH access to your Ubuntu server. SSH, or Secure Shell, is a network protocol that gives you the ability to securely access your server over an unsecured network. If you're not familiar with SSH, consider reading a quick guide on how to use it.

Updating Ubuntu

Updating your Ubuntu server is straightforward but requires attention to detail. The process involves refreshing your package list, upgrading packages, and then cleaning up. Here's how you do it:

  1. Connect to your server: Open your terminal and connect to your server via SSH using the command ssh username@your_server_ip.
  2. Update package list: Run sudo apt update to refresh your package list. This command fetches the latest versions of packages and their dependencies but doesn't install them.
  3. Upgrade packages: Execute sudo apt upgrade to install the new versions of the packages.
  4. Clean up: After upgrading, some packages might no longer be needed. Use sudo apt autoremove to remove them.

Using Third-Party Repositories: Sury Repository for PHP/Nginx/Bind9

For more up-to-date versions of PHP, Nginx, and Bind9, you might want to use third-party repositories like packages.sury.org. Here's how to add the Sury repository to your Ubuntu server:

  1. First, install the necessary packages: sudo apt install -y software-properties-common.
  2. Add the repository: sudo add-apt-repository ppa:ondrej/php.
  3. Update your package list again: sudo apt update.
  4. Now, you can install new versions of PHP.

Additional Tips

Keeping your Ubuntu server updated is crucial for security and performance. Here are some additional tips:

  • Regularly check for updates and apply them promptly.
  • Consider setting up automatic updates for critical security patches.
  • Always back up your server before applying updates, especially for major releases.