How to Upgrade WordPress from the Command Terminal

social media 3553807 640
social media 3553807 640

The post provides step-by-step instructions for upgrading a WordPress website via SSH terminal console. It highlights the methods for backing up database and content, removing old directories, downloading the latest WordPress files, and copying these files into the root directory. Instructions also include the initiation of the upgrade process and ensuring updated changes post-process completion.

This post shows students and new users steps to upgrade WordPress via SSH terminal console. When running a WordPress website, one task you’ll have to learn quickly is upgrading or updating WordPress content.

If lucky, you may have a WordPress website that automatically updates when new versions are released. If that’s the case, then you should be all set. Nothing to do but sit and relax.

However, not all WordPress websites are configured to upgrade automatically when new versions are released. If your WordPress site is configured and can not self-update, you may have to update from the server console or use other means.

An easy way to update WordPress content is from the server terminal. One can get to the server console via SSH or directly. Once on the terminal console, you can easily upgrade WordPress.

When you’re ready to update or upgrade WordPress via SSH terminal, continue below:

How to backup WordPress database

Before making changes to your WordPress site, it is recommended that you always back up your database content. If you’re running MySQL or MariaDB database server, the commands below are how to back up a database.

sudo mysqldump -u root -p wp_database > wp_database.sql

Replace wp_database with the WordPress database that you want to back up. If you have a plugin that can backup WordPress content, then use it to backup WordPress before continuing below.

How to backup WordPress content

You may also want to back up WordPress content. Assuming WordPress is installed in the /var/www/wordpress, use Rsync to copy the WordPress content directory to a backup location.

To do that, run the commands below.

sudo rsync -Waq /var/www/wordpress  /path/to/backup/directory/

After backing up the WordPress database and content, continue below to begin upgrading WordPress.

Delete WordPress wp-includes and wp-admin folders

To begin upgrading, delete the existing wp-admin and wp-include directories.

sudo rm -rf /var/www/wordpress/wp-includes
sudo rm -rf /var/www/wordpress/wp-admin

After deleting WordPress existing folders for wp-admin and wp-includes folders, download WordPress updated content.

How to Download WordPress content

To download the latest WordPress content, simply run the commands below. Once the content is downloaded, the next command extracts it.

cd /tmp/ && wget

Unzip the download content using the commands below.


Replace WordPress content with the latest

Finally, run the commands below to copy WordPress’s latest content to the root directory. Doing this will replace the wp-includes and wp-admin folders and overwrite any other folders with newer versions.

sudo mv /tmp/wordpress/* /var/www/wordpress

After copying the files, open your browser and browse the WordPress URL for the site to initiate the upgrade.

Replace in the URL with your domain.

After a brief moment, your WordPress site should be updated with the latest files. You can then log in to see the changes.

That’s it!


This post showed you how to upgrade WordPress. Please use the comment form below if you find any errors above or have something to add.

Posted by

I love computers; maybe way too much. What I learned I try to share at

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.