Useful WP-CLI commands

Search another help topic

WP-CLI lets you manage WordPress from Terminal. Use the commands below to update WordPress core, manage plugins and users, and change key settings.

Before you start

You’ll need:

  • SSH or Terminal access to your hosting account
  • WP-CLI installed on the server — this is included with Ecenica hosting
  • Your WordPress files — run each command from the folder that contains wp-config.php

Back up your site before you update core, change users, or run search and replace.

Update WordPress core

Use these commands to check your version and update WordPress safely.

Check your current version

wp core version

This shows the installed WordPress version, for example 6.8.1.

Check for available updates

wp core check-update

This lists any newer version available from WordPress.org. If you’re already up to date, you’ll see a success message.

Update WordPress to the latest version

wp core update

This downloads and installs the latest WordPress files. Run it from your WordPress root folder.

Update the WordPress database

wp core update-db

Run this after updating files. Some releases need a database update to finish the process.

Update to a specific version

wp core update --version=6.8 --force

Replace 6.8 with the version you need. Use --force only when you must reinstall or roll back to that version.

Update to the latest minor release only

wp core update --minor

This applies security and maintenance updates, for example from 6.8 to 6.8.1, without moving to a new major version.

List active plugins

wp plugin list --status=active

This shows each active plugin with its version and update status.

Install a plugin

wp plugin install hello-dolly

Replace hello-dolly with the plugin slug you want to install. The slug is usually the folder name in wp-content/plugins.

Activate a plugin

wp plugin activate hello-dolly

Replace hello-dolly with your plugin slug.

Install and activate a plugin in one step

wp plugin install hello-dolly --activate

This installs the plugin and turns it on straight away.

Deactivate a plugin

wp plugin deactivate hello-dolly

Replace hello-dolly with the slug of the plugin you want to turn off. This is useful if a faulty plugin locks you out of wp-admin.

Delete a plugin

wp plugin delete hello-dolly

Replace hello-dolly with your plugin slug. Deactivate the plugin first if it is still active.

List WordPress users

wp user list

This shows usernames, email addresses, and roles for all users on your site.

Change your WordPress password

wp user update admin --user_pass=your-new-password

Replace admin with your username and your-new-password with a strong password. You can then log in with the new details.

Change a WordPress username

Run a dry run first to preview changes without saving them. Replace old_username and new_username with your values.

wp search-replace old_username new_username --dry-run

When you’re happy with the preview, run it without --dry-run to save changes.

wp search-replace old_username new_username

Stop search engines from indexing your site

wp option update blog_public 0

This sets WordPress to discourage search engines. Use 1 instead of 0 to allow indexing again.

Password protect your whole site

These three commands install the Password Protected plugin, set a password, and turn protection on. Replace yourpassword with your own password.

wp plugin install password-protected --activate

wp option update password_protected_password 'yourpassword'

wp option update password_protected_status '1'

Visitors must then enter the password before they can view any page.

Troubleshooting

Where do I run these commands?

Run them from your WordPress root folder over SSH, the same folder that contains wp-config.php.

Do I need a backup before wp core update?

Yes. Take a full backup of files and database first so you can restore if an update fails.

What if I see "Another update is currently in progress"?

Check no other update is running, then run wp option delete core_updater.lock and try wp core update again.

How do I learn more WP-CLI commands?

See WordPress Developer Resources WP-CLI Commands.

Related articles

  • /support/answer/how-to-log-into-wordpress-dashboard/
  • /support/answer/how-to-install-a-wordpress-theme/
  • /support/answer/how-to-transfer-wordpress/
  • /support/answer/install-w3-total-cache/

If you need help, contact Ecenica support and link to this guide.

Need help with this?

Open a ticket and link to this guide so our team can see what you have tried.

View support tickets

Power your business with Ecenica Hosting

Built for WordPress and serious websites. Fast, secure and supported by real people in the UK.

Ecenica hosting services represented by a connected red route across London