WP-CLI is an open-source command-line tool that allows you to manage WordPress websites directly from the terminal. In this article, I’ll show you how to update WordPress to the latest release or a specific version, using WP-CLI. Let’s begin.
SSH to your server and use this command to check if you have WP-CLI installed:
wp --info
If WP-CLI is not installed, follow this tutorial to install it.
Then use cd command to navigate to the WordPress installation directory, for example:
cd /var/www/public/wordpressCode language: Shell Session (shell)
Use this command to check for latest update:
wp core check-update
Use this command to update to the latest version:
wp core update
Or if you want to update to a specific version instead of the latest one, use this command (type the version number after the --version= parameter):
wp core update --version=6.8.1
The terminal will download and install the update for you. Once the update is complete, run the following command to update the database:
wp core update-db
The final command to flush the cache and finish the update:
wp cache flush
Check out more related commands in the official documentation.