1. Home
  2. Knowledge Base
  3. WordPress
  4. What is WP-CLI? What is WP-CLI used for?

What is WP-CLI? What is WP-CLI used for?

The name comes from ‘WordPress Command Line Interface’ – WP-CLI. You can use WP-CLI to manage WordPress and:

  • Detect errors and issues and fix them
  • Bypass using the interface when the backend is unavailable
  • Do regular maintenance and updates

This article lists several useful commands for you, but the list is non-exhaustive. Click on the link to explore more WP-CLI commands.

IN THIS ARTICLE:

How do I use WP-CLI

WP-CLI is installed on all Webhosting packages in Easyhost. All you have to do is connect to the account via SSH. For Windows you can use a free SSH client such as Putty. For Linux and Mac, simply use your terminal.

All of the following WP-CLI commands have to be executed from the directory where your WordPress website is installed. To change the current directory, simply use the cd command, for example:

cd www/ 

User management commands in WP-CLI

Create user

This command will create a new user with username “username” with the specified permissions, e-mail address and password.

wp user create username-here your-email@address.com --role=administrator --user_pass=password-here

Delete user

This command will delete the user with the specified username – in this case “username”.

wp user delete username

List all users

The following command will show you all users in your CMS with their ID, display name, e-mail address and permissions/role.

wp user list

Edit password for a user

Use the numeric ID from the output of the previous command to edit the password for a user of your choice

wp user update 1 --user_pass=new-password-here

WordPress updates via WP-CLI

WordPress core

Check the current WordPress core version:

wp core version

Update the WordPress core to the latest available version

wp core update

If you need to update to a particular version, for example if a plugin you use is incompatible with the latest WordPress available, you can force WordPress to update to a version of your choice. The example below would update your CMS to WordPress v4.5

wp core update --version=4.5 --force

Themes

Check the current status and update availability of all themes

wp theme list

OR

wp theme status

where you see the name, the version and a letter indicator – I = Inactive, A = Active, U = Update Available

Check for outdated themes only:

wp theme list | grep "available"

Update all themes:

wp theme update --all

Plugins

Check the current status and update availability of all plugins

wp plugin list

OR

wp plugin status

where you see the name, the version and a letter indicator – I = Inactive, A = Active, U = Update Available

Check for outdated plugins only:

wp plugin list | grep "available"

Update all plugins:

wp plugin update --all

Update one plugin only:

wp plugin update name-of-plugin

Plugin management

Deactivate all plugins

wp plugin deactivate --all

Activate all plugins

wp plugin activate --all

(De)activate particular plugin

wp plugin deactivate name-of-plugin

OR

wp plugin activate name-of-plugin
Updated on 20 May 2020

Was this article helpful?