Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Developer · Guide

WP-CLI Commands You'll Use Every Week

WP-CLI Commands You'll Use Every Week

Short answer

WP-CLI is the command-line interface for WordPress, and it lets you update core, themes, and plugins, manage users, work with the database, and fix a broken site from the terminal. The commands you will use most are wp core update, wp plugin update, wp theme update, wp user, wp db, wp search-replace, and wp rewrite flush. Always back up first, and preview changes with --dry-run where the command offers it.

Key takeaways

  • WP-CLI runs WordPress admin tasks from the terminal, including updates, user management, and database work.
  • WP-CLI needs PHP 7.2.24 or later, and the Phar install is downloaded, made executable, and moved to /usr/local/bin/wp.
  • Run wp --info first to check the environment, then list plugins, themes, and the database size before changing anything.
  • Preview plugin updates and domain moves with --dry-run, because db import, search-replace, and plugin update cannot be undone.
  • Run commands as the site user, never as root, and deactivate plugins one at a time to find the one that breaks a site.

What is WP-CLI?

WP-CLI is the command-line interface for WordPress, and it runs admin tasks from a terminal instead of the dashboard.

WP-CLI lets you install, update, and manage a WordPress site with typed commands. The WP-CLI handbook describes it as the command-line interface for WordPress, used to do admin and development tasks in a set, repeatable way (checked November 2026).

You type wp followed by a command, and WP-CLI runs it against the WordPress files in your current folder. That makes it useful for bulk work, such as updating 20 plugins at once, which would take many clicks in the dashboard.

The full command list covers core, plugins, themes, users, posts, media, options, and the database. Developer.WordPress.org lists commands such as wp core, wp plugin, wp theme, wp user, wp post, wp media, wp option, wp db, and wp search-replace (checked November 2026).

WP-CLI is free and open source, and it runs on the server where your WordPress files live. It does not replace the dashboard, but it gives you a faster route for repeat jobs and for repairs when the dashboard will not load.

What do you need before you run WP-CLI?

You need shell access to the server, PHP 7.2.24 or later, and a WordPress install to point the commands at.

The WP-CLI handbook states that WP-CLI requires PHP 7.2.24 or later, and that it has no extra needs beyond those of WordPress itself (checked November 2026).

Check the PHP version your server offers before you install anything. WordPress.org states that WordPress recommends PHP 8.3 or greater, and that WordPress still works with PHP 7.4 and later in older setups (checked November 2026).

You also need a way to reach the server terminal, usually SSH through your host control panel. If your host does not offer shell access, ask support whether WP-CLI is already installed or whether a terminal is available on your plan.

Run commands as the site owner account, not as root. The WordPress hosting handbook warns that running as root can leave files owned by root that the web server cannot write to later (checked November 2026).

A guide on how to set up a staging site for WordPress shows how to build a safe copy of your site for practice before you run commands on the live site.

How do you install WP-CLI?

Download the wp-cli.phar file, check that it runs, make it executable, and move it into a folder on your PATH.

The handbook recommends the Phar build as the install method. The WP-CLI handbook states that you download the Phar build, mark it executable, and place it on your PATH (checked November 2026).

Run these four steps in order:

  1. Download the file with curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar.
  2. Check that it works with php wp-cli.phar --info.
  3. Make it executable with chmod +x wp-cli.phar.
  4. Move it with sudo mv wp-cli.phar /usr/local/bin/wp.

Update a Phar install with wp cli update. The WP-CLI handbook states that a Phar install can be updated at any time with wp cli update, or with sudo wp cli update when root owns the file (checked November 2026).

How do you check the site before you change it?

Run wp --info first, then check the WordPress version, the plugin list, and the database size before you change anything.

wp --info prints the WP-CLI version, the PHP binary and version, and the config WP-CLI is using. The WordPress hosting handbook recommends this as the first check, since it shows the environment each later command will use (checked November 2026).

Use these commands to learn the state of the site:

wp --info
wp core version --extra
wp plugin list
wp theme list
wp db size --human-readable

wp core version --extra shows the WordPress version plus extra detail about the install. wp plugin list shows every plugin, its status, and its version in one table, so you can spot an out-of-date plugin fast.

wp db size --human-readable shows how large the database is in plain units. The WordPress hosting handbook lists wp db size --human-readable and wp db size --tables among the database checks to run before export or import work (checked November 2026).

Point WP-CLI at the right site when you are not in the WordPress folder. The WordPress hosting handbook states that you use --path=/path/to/wordpress when you are not in the WordPress folder, and --url=https://site.example.com on multisite to target one site (checked November 2026).

Which commands update WordPress, themes, and plugins?

Use wp core update, wp plugin update, and wp theme update, and preview plugin updates with --dry-run first.

Start with a full backup, because updates change live files. A guide on how to back up a WordPress database covers the database half of that backup before you update anything.

List what is out of date before you update it:

wp plugin list --update=available
wp plugin update --all --dry-run
wp plugin update --all
wp theme update --all
wp core update

wp plugin list --update=available shows only the plugins with an update waiting. The WordPress hosting handbook advises running --dry-run first to see what would be updated without changing anything (checked November 2026).

wp core update downloads and installs the latest WordPress core. wp plugin update --all updates every plugin, and wp theme update --all updates every theme, so run them one at a time and check the site after each.

CommandWhat it doesWhen to use it
wp core version --extraShows the WordPress versionBefore any update
wp core updateUpdates WordPress coreWhen a new release is out
wp plugin list --update=availableLists plugins with updatesBefore a plugin update run
wp plugin update --allUpdates all pluginsAfter a backup, with --dry-run first
wp theme update --allUpdates all themesAfter a backup
wp core verify-checksumsChecks core files against the official releaseWhen you suspect changed files

How do you fix a site that will not load?

Deactivate all plugins from the command line, then switch them back on one at a time to find the one that breaks the site.

A broken plugin is a common cause of a blank dashboard, and WP-CLI can reach the site when the dashboard cannot. The WordPress hosting handbook gives this exact method for a site where the dashboard is not reachable (checked November 2026).

Run these commands from the WordPress folder:

wp plugin deactivate --all
wp plugin activate plugin-slug

Replace plugin-slug with the folder name of one plugin, such as akismet. Activate one plugin, reload the site, and repeat until the fault returns. The last plugin you switched on is the likely cause.

If a fatal error stops every command, start WP-CLI without loading plugins or themes. The WordPress hosting handbook states that adding --skip-plugins and --skip-themes lets WP-CLI start when a fatal error blocks normal commands (checked November 2026).

That fallback looks like this:

wp plugin list --skip-plugins --skip-themes

A guide on how to fix a plugin conflict walks through the same one-by-one method in the dashboard, which pairs well with the command-line version here.

Which commands manage users and roles?

Use wp user to list, create, and update users, and wp role to list roles and reset them to the defaults.

Developer.WordPress.org describes wp user as the command that manages users, along with their roles, capabilities, and meta, and wp role as the command that manages user roles, including creating new roles (checked November 2026).

Common user jobs look like this:

wp user list
wp user list --role=administrator
wp user create editor1 [email protected] --role=editor
wp user update 5 --role=author
wp user delete 5 --reassign=2

wp user list --role=administrator shows every admin account, which is a fast way to spot an admin you did not create. wp user delete with --reassign moves the deleted user posts to another user instead of deleting them.

Reset a changed role back to the WordPress defaults with wp role reset. Developer.WordPress.org states that wp role manages user roles, including creating new roles and resetting them to the defaults (checked November 2026).

Give a user the lowest role that still lets them do their job. An editor can publish other people posts, while a contributor cannot publish at all, so the choice of role is a security choice as much as a workflow choice.

How do you move a site to a new domain?

Use wp search-replace with --dry-run first, then run it for real, and finish with wp rewrite flush.

wp search-replace swaps one string for another across the database, which is what a domain move needs. Developer.WordPress.org describes wp search-replace as the command that searches and replaces strings in the database (checked November 2026).

Run the dry run first so you can see every change before it happens:

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
wp rewrite flush

The WordPress hosting handbook states that --skip-columns=guid keeps the GUID column untouched, and that the dry run shows what would change before anything is written (checked November 2026).

Take a full backup before you run wp search-replace without --dry-run. The WordPress hosting handbook warns that several commands, including db import, search-replace, and plugin update, cannot be undone, so a backup comes first (checked November 2026).

wp rewrite flush rebuilds the rewrite rules after the move, so permalinks keep working at the new address. A guide on how to migrate WordPress with WP-CLI covers the full move, including the file copy that goes with the database change.

Which commands work with the database?

Use wp db check, wp db export, wp db import, and wp db size for checks, backups, and restores.

wp db runs database work with the login details already stored in wp-config.php. Developer.WordPress.org describes wp db as the command that performs basic database operations using the credentials stored in wp-config.php (checked November 2026).

The four commands you will use most are:

wp db check
wp db size --tables
wp db export /path/outside/webroot/backup.sql
wp db import /path/outside/webroot/backup.sql

wp db check looks for errors in the tables, while wp db size --tables breaks the total size down by table. The WordPress hosting handbook lists both among the database checks to run before export or import work (checked November 2026).

Store the export outside the web root, so the backup file is not reachable from a browser. The export path in the example above sits outside the site folder on purpose, and the same path is used to import it back.

wp db import replaces the live database with the file you point it at, so it wipes the current data. Back up first, and double-check the file name before you press Enter.

A guide on how to optimize the WordPress database explains what to clean up once you know which tables are the largest.

How do you check cron jobs and rewrite rules?

Use wp cron to list and run scheduled events, and wp rewrite to list or flush the permalink rules.

Developer.WordPress.org describes wp cron as the command that tests, runs, and deletes WP-Cron events, and wp rewrite as the command that lists or flushes rewrite rules and updates the permalink structure (checked November 2026).

These checks help when a scheduled post never publishes or a permalink returns a 404:

wp cron event list
wp cron event run --due-now
wp rewrite list
wp rewrite flush

wp cron event list shows each scheduled event and its next run time. wp cron event run --due-now runs only the events that are due, which is a safe way to catch up a stuck schedule without running future events early.

wp rewrite list prints the current rules, and wp rewrite flush rebuilds them. Flush the rules after a domain move, a permalink change, or a plugin that registers new URL patterns.

What mistakes should you avoid?

Avoid running commands as root, skipping the backup, and running a live search-replace without a dry run first.

Running as root is the first mistake to fix. The WordPress hosting handbook states that you should run commands as the site user, not as root, and use sudo -u with the site user name instead of --allow-root (checked November 2026).

Skipping the backup is the second mistake. Commands such as db import, search-replace, and plugin update cannot be undone, so a backup is the only way back when a command goes wrong (checked November 2026).

Running a command in the wrong folder is the third mistake. WP-CLI works on the WordPress install in your current folder, so cd into the right site folder first, or pass --path with the full path to the install.

The fifth mistake is typing a live command when a dry run was offered. wp plugin update --all --dry-run and wp search-replace ... --dry-run both exist so you can preview the change, and the preview costs seconds while a bad live run can cost hours.

Frequently asked questions

Can I use WP-CLI on shared hosting?

Yes, if your host gives you shell access. Many hosts install WP-CLI for you, and some offer it through a package manager. If your plan has no terminal access, ask your host whether WP-CLI is available or whether a terminal can be added to your plan.

Is WP-CLI safe to run on a live site?

No. WP-CLI only changes what the command you run tells it to change. Read the command first, run a dry run where one is offered, and back up before commands that write to the database or the files, such as db import, search-replace, and plugin update.

What should I do when the dashboard will not load?

Run wp plugin deactivate --all, then switch plugins back on one at a time until the fault returns. If a fatal error blocks every command, add --skip-plugins and --skip-themes so WP-CLI can start without loading them.

Why does wp say no WordPress installation was found?

It means WP-CLI ran the command against the wrong folder, or the wrong site on a multisite network. Move into the WordPress folder first, or pass --path with the full path and --url with the site address on multisite.

Can WP-CLI change my site domain?

Yes. Use wp search-replace with the old domain and the new domain, and add --skip-columns=guid to keep the GUID column untouched. Run it with --dry-run first to preview every change, then run it again without that flag and finish with wp rewrite flush.

How do I back up the database with WP-CLI?

Use wp db export to save a copy and wp db import to restore it, with the file stored outside the web root. Run wp db check first to look for table errors, and wp db size --tables to see which tables are the largest.

Sources

  1. WP-CLI Commands WordPress Developer Resources
  2. Installing WP-CLI Make WordPress
  3. WP-CLI - WordPress Hosting Handbook Make WordPress
  4. Requirements WordPress.org
  5. PHP Manual PHP.net

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.