CMS

How to Update WordPress Using SSH Terminal

Richard
Written by
Richard
Oct 2, 2021 Updated Mar 18, 2026 4 min read

This post shows steps for students and new users to upgrade WordPress via the 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.

🐧Bash / Shell
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.

🐧Bash / Shell
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.

🐧Bash / Shell
sudo rm -rf /var/www/wordpress/wp-includes
sudo rm -rf /var/www/wordpress/wp-admin

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

How to Download WordPress content

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

Command Prompt
cd /tmp/ && wget https://wordpress.org/latest.zip

Unzip the downloaded content using the commands below.

💻Code
unzip latest.zip

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.

🐧Bash / Shell
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.

🐘PHP
http://www.example.com/wp-admin/upgrade.php

Replace www.example.com 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!

Conclusion:

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.

Frequently Asked Questions

How do I update WordPress using SSH?

To update WordPress using SSH, you need to access your server terminal via SSH. Once logged in, back up your database and content, delete the existing wp-admin and wp-includes folders, download the latest WordPress content, and then replace the old files with the new ones.

What commands do I need to back up my WordPress database?

You can back up your WordPress database using the command: `sudo mysqldump -u root -p wp_database > wp_database.sql`. Replace 'wp_database' with the name of your actual WordPress database.

Is it necessary to back up my WordPress site before updating?

Yes, it is highly recommended to back up your WordPress site before performing any updates. This ensures that you can restore your site to its previous state in case anything goes wrong during the update process.

How can I download the latest version of WordPress?

You can download the latest version of WordPress by running the command: `cd /tmp/ && wget https://wordpress.org/latest.zip`. After downloading, unzip the file using the command `unzip latest.zip`.

What should I do after replacing WordPress files?

After replacing the WordPress files, you should visit your site's upgrade URL at `http://www.example.com/wp-admin/upgrade.php` to complete the upgrade process. Make sure to replace 'www.example.com' with your actual domain.

Was this guide helpful?

Tags: #WordPress
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

Leave a Reply

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

Exit mobile version