Title: WP-CLI
Author: WordPress.org
Published: 2026-11-05

---

# WP-CLI

## In this article

 * [Running WP-CLI on a server](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#running-wp-cli-on-a-server)
 * [Site health and integrity](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#site-health-and-integrity)
 * [Plugins and themes](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#plugins-and-themes)
 * [Database](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#database)
 * [Migrations and domain changes](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#migrations-and-domain-changes)
 * [Caches, rewrites and cron](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#caches-rewrites-and-cron)
 * [Maintenance mode](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#maintenance-mode)
 * [Users and security](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#users-and-security)
 * [Configuration and options](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#configuration-and-options)
 * [Media](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#media)
 * [Multisite](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#multisite)

[WP-CLI](https://wp-cli.org/) is the command-line interface for WordPress. It lets
hosts and support teams check, maintain and repair a site from the serverServer 
A server is a piece of computer hardware or software that provides functionality
for other programs or devices. Typical servers are database servers, file servers,
mail servers, print servers, web servers, game servers, and application servers.
without logging in to the WordPress admin. This page lists the commands that are
most useful for hostingHosting A web hosting service is a type of Internet hosting
service that allows individuals and organizations to make their website accessible
via the World Wide Web. work. For every command and option, see the official [WP-CLI command reference](https://developer.wordpress.org/cli/commands/).

For upgrading WordPress coreCore Core is the set of software required to run WordPress.
The Core Team builds WordPress. with WP-CLIWP-CLI WP CLI is the Command Line Interface
for WordPress, used to do administrative and development tasks in a programmatic
way., see [Upgrading](https://make.wordpress.org/hosting/handbook/upgrading/).

Always take a full backupBackup A backup is a copy of computer data taken and stored
elsewhere so that it may be used to restore the original after a data loss event.
Backups can be used to recover data after its loss from data deletion or corruption,
or to recover data from an earlier time. Backups provide a simple form of disaster
recovery. of the files and the databaseDatabase A database is an organized collection
of data. Access to this data is usually provided by a “database management system”(
DBMS) consisting of an integrated set of computer software that allows users to 
interact with one or more databases and provides access to all of the data contained
in the database. Because of the close relationship between them, the term “database”
is often used casually to refer to both a database and the DBMS used to manipulate
it. before running commands that change a site. Several commands on this page (`
db import`, `search-replace`, `plugin update`) cannot be undone.

## 󠀁[Running WP-CLI on a server](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#running-wp-cli-on-a-server)󠁿

 * **Run commands as the site’s user, not as root.** Running as root can leave files
   owned by root that the web server cannot write to later. Use `sudo -u <site-user
   > wp <command>` rather than `--allow-root`.
 * **Point WP-CLI at the right site.** Use `--path=/path/to/wordpress` when you 
   are not in the WordPress directory. On multisite, add `–url=https://site.example.
   com` to run a command against a single site.
 * **Check the environment first.** `wp --info` shows the WP-CLI version, the PHP
   binary and version, and the configuration WP-CLI is using. The PHP version used
   on the command line can differ from the one used by the web server.

    ```bash
    wp --info
    wp cli version
    wp cli update
    ```

`wp cli update` only works when WP-CLI was installed as a Phar file. If it was installed
through a package manager, update it there.

## 󠀁[Site health and integrity](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#site-health-and-integrity)󠁿

    ```bash
    wp core version --extra
    wp core verify-checksums
    wp plugin verify-checksums --all
    ```

`verify-checksums` compares files against the official release from WordPress.org,
so modified or injected files show up. Plugin checksums are only available for plugins
hosted on WordPress.org.

On WordPress 7.x sites downloaded with `wp core download` from WP-CLIWP-CLI WP CLI
is the Command Line Interface for WordPress, used to do administrative and development
tasks in a programmatic way. 2.12 or older, `verify-checksums` reports files under`
wp-includes/php-ai-client/` as missing, and cut-off file names as “should not exist”.
This is a WP-CLI extraction bug ([wp-cli/wp-cli#6320](https://github.com/wp-cli/wp-cli/issues/6320)),
not a modified coreCore Core is the set of software required to run WordPress. The
Core Team builds WordPress.. `wp core download --force --skip-content` restores 
the files.

## 󠀁[Plugins and themes](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#plugins-and-themes)󠁿

    ```bash
    wp plugin list
    wp plugin list --update=available
    wp plugin update --all --dry-run
    wp plugin update --all
    wp theme list
    wp theme update --all
    ```

Run `--dry-run` first to see what would be updated without changing anything.

When a plugin breaks a site and the dashboard is not reachable, deactivate plugins
from the command line to find the cause:

    ```bash
    wp plugin deactivate --all
    wp plugin activate <plugin-slug>
    ```

To start WP-CLI without loading plugins or themes, for example when a fatal error
stops every command, add `--skip-plugins` and `--skip-themes`:

    ```bash
    wp plugin list --skip-plugins --skip-themes
    ```

## 󠀁[Database](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#database)󠁿

    ```bash
    wp db check
    wp db size --human-readable
    wp db size --tables
    wp db export /path/outside/webroot/backup.sql
    wp db import /path/outside/webroot/backup.sql
    ```

`wp db export` and `wp db import` use the database credentials in `wp-config.php`.
Store exports outside the web root, and delete them when they are no longer needed.

## 󠀁[Migrations and domain changes](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#migrations-and-domain-changes)󠁿

    ```bash
    wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid --dry-run
    wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid
    ```

`search-replace` handles serialized data correctly, which a plain SQL `REPLACE()`
does not. Always run it with `--dry-run` first and check the number of replacements.
The `guid` column should not be changed on an existing site. On multisite, add `--
network` so the tables of every site in the network are included.

## 󠀁[Caches, rewrites and cron](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#caches-rewrites-and-cron)󠁿

    ```bash
    wp cache flush
    wp transient delete --expired
    wp rewrite flush
    wp cron test
    wp cron event list
    wp cron event run --due-now
    ```

`wp cache flush` clears the object cache. It does not clear a page cache or a CDN,
which usually have their own commands or controls.

`wp cron test` checks whether WP-Cron can be triggered over HTTP. If you disable
WP-Cron with `DISABLE_WP_CRON` and run it from a system cron job, `wp cron event
run --due-now` is a common way to do that. On those sites `wp cron test` returns
an error, which is expected.

## 󠀁[Maintenance mode](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#maintenance-mode)󠁿

    ```bash
    wp maintenance-mode status
    wp maintenance-mode activate
    wp maintenance-mode deactivate
    ```

## 󠀁[Users and security](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#users-and-security)󠁿

    ```bash
    wp user list --role=administrator
    wp super-admin list
    wp user reset-password <user>
    wp user session destroy <user> --all
    wp config shuffle-salts
    ```

After a compromise, list the administrator accounts (and, on multisite, the super
admins, who do not need a role on the main site) and remove any that should not 
be there, reset passwords, and destroy existing sessions. `wp config shuffle-salts`
replaces the keys and salts in `wp-config.php`, which logs every user out. See the
[Security](https://make.wordpress.org/hosting/handbook/security/) page for more.

## 󠀁[Configuration and options](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#configuration-and-options)󠁿

    ```bash
    wp config list
    wp config get WP_DEBUG
    wp option get siteurl
    wp option get home
    ```

`wp config list` shows the constants and variables defined in `wp-config.php`, and`
wp config get` shows a single one. Be careful when sharing the output of `wp config
list`, because it includes database credentials and keys.

## 󠀁[Media](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#media)󠁿

    ```bash
    wp media regenerate --only-missing
    ```

Regenerates missing thumbnail sizes, for example after a theme change or a migration.
Without `--only-missing`, every thumbnail is regenerated, which can take a long 
time on large sites. The command asks for confirmation, so add `--yes` when running
it from a script.

## 󠀁[Multisite](https://make.wordpress.org/hosting/handbook/wp-cli/?output_format=md#multisite)󠁿

    ```bash
    wp site list
    wp plugin list --url=https://site.example.com
    ```

Most commands accept `--url` to target one site in a network.

If you’re interested in improving this handbook, check the [GitHub Handbook repo](https://github.com/WordPress/hosting-handbook/),
or leave a message in the [#hosting channel](https://wordpress.slack.com/archives/hosting/)
of the official [WordPress Slack](https://make.wordpress.org/chat/).

First published

2026-11-05

Last updated

2026-11-05

Edit article

[ Improve it on GitHub: WP-CLI ](https://github.com/wordpress/hosting-handbook/edit/main/wp-cli.md)

Changelog

[ See list of changes: WP-CLI ](https://github.com/wordpress/hosting-handbook/commits/main/wp-cli.md)

[  Previous: Learn Hosting](https://make.wordpress.org/hosting/handbook/learn-hosting/)

[  Next: Performance](https://make.wordpress.org/hosting/handbook/performance/)