Home/Knowledge Base/WordPress/WordPress WP-CLI Complete Command Reference

WordPress WP-CLI Complete Command Reference

18 Jun, 2026
5 min read

Overview

WP-CLI is the official command-line interface for WordPress. It lets you install plugins, manage users, update core, import/export databases, flush caches, and perform dozens of other tasks — all without opening a browser. On CloudStick-managed servers, WP-CLI is the most efficient way to automate and script WordPress administration tasks directly from your server's SSH terminal.

This reference covers every major WP-CLI command group: core, users, plugins, themes, database, options, cache, posts, media, cron, maintenance mode, and backups. All commands use --allow-root since CloudStick servers run as root, and include --path= pointing to your site's root directory. Replace /home/[user]/apps/[site] with your actual site path in all commands below.

Always take a full backup (database + files) before running update or delete commands. See Section 12 for the backup commands to run first.

Section 1: WP-CLI Installation

Skip this section if WP-CLI is already installed on your server. Run wp --allow-root cli version to check — if it returns a version number, WP-CLI is already available.

Install WP-CLI

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

Verify Installation

wp --allow-root cli version
wp --allow-root cli info

Section 2: WordPress Core

Check your WordPress version, apply core updates, verify file integrity, and keep the database schema in sync after upgrading.

Check Current Version

wp --path=/home/[user]/apps/[site] --allow-root core version

Check for Available Updates

wp --path=/home/[user]/apps/[site] --allow-root core check-update

Update WordPress Core

wp --path=/home/[user]/apps/[site] --allow-root core update

Update Database After Core Update

wp --path=/home/[user]/apps/[site] --allow-root core update-db

Verify Core File Integrity (Check for Tampering)

wp --path=/home/[user]/apps/[site] --allow-root core verify-checksums

Download Fresh WordPress (Force Overwrite)

wp --path=/home/[user]/apps/[site] --allow-root core download --force

Update Everything in One Command

wp --path=/home/[user]/apps/[site] --allow-root core update && \
wp --path=/home/[user]/apps/[site] --allow-root core update-db && \
wp --path=/home/[user]/apps/[site] --allow-root plugin update --all && \
wp --path=/home/[user]/apps/[site] --allow-root theme update --all

Section 3: User Management

List, create, update, and delete WordPress users from the command line — useful for bulk operations or recovering admin access.

List All Users

wp --path=/home/[user]/apps/[site] --allow-root user list

List Users with Specific Fields

wp --path=/home/[user]/apps/[site] --allow-root user list --fields=ID,user_login,user_email,roles

Get Details of a User

wp --path=/home/[user]/apps/[site] --allow-root user get 1

Update User Password (by ID)

wp --path=/home/[user]/apps/[site] --allow-root user update 1 --user_pass="NewPass@123"

Update User Password (by Username)

wp --path=/home/[user]/apps/[site] --allow-root user update admin --user_pass="NewPass@123"

Update User Email

wp --path=/home/[user]/apps/[site] --allow-root user update 1 --user_email="new@example.com"

Create New Admin User

wp --path=/home/[user]/apps/[site] --allow-root user create john john@example.com --role=administrator --user_pass="Pass@123"

Delete User (Reassign Posts to User ID 1)

wp --path=/home/[user]/apps/[site] --allow-root user delete 2 --reassign=1

Send Password Reset Email

wp --path=/home/[user]/apps/[site] --allow-root user reset-password 1

Section 4: Plugin Management

Install, activate, deactivate, update, and remove plugins without accessing the WordPress admin dashboard.

List All Plugins

wp --path=/home/[user]/apps/[site] --allow-root plugin list

Install a Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin install woocommerce

Install and Activate a Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin install woocommerce --activate

Activate a Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin activate woocommerce

Deactivate a Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin deactivate woocommerce

Deactivate ALL Plugins

wp --path=/home/[user]/apps/[site] --allow-root plugin deactivate --all

Update Specific Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin update woocommerce

Update All Plugins

wp --path=/home/[user]/apps/[site] --allow-root plugin update --all

Delete a Plugin

wp --path=/home/[user]/apps/[site] --allow-root plugin delete woocommerce

Check Plugin Status

wp --path=/home/[user]/apps/[site] --allow-root plugin status woocommerce

Section 5: Theme Management

Install, activate, update, and remove themes directly from the command line.

List All Themes

wp --path=/home/[user]/apps/[site] --allow-root theme list

Install a Theme

wp --path=/home/[user]/apps/[site] --allow-root theme install astra

Install and Activate a Theme

wp --path=/home/[user]/apps/[site] --allow-root theme install astra --activate

Activate a Theme

wp --path=/home/[user]/apps/[site] --allow-root theme activate astra

Update Specific Theme

wp --path=/home/[user]/apps/[site] --allow-root theme update astra

Update All Themes

wp --path=/home/[user]/apps/[site] --allow-root theme update --all

Delete a Theme

wp --path=/home/[user]/apps/[site] --allow-root theme delete twentytwenty

Section 6: Database Operations

Export, import, optimize, repair, and query the WordPress database. The search-replace command is particularly useful after migrating a site to a new domain.

Export Database Backup

wp --path=/home/[user]/apps/[site] --allow-root db export /home/[user]/backup_$(date +%F).sql

Import Database

wp --path=/home/[user]/apps/[site] --allow-root db import /home/[user]/backup.sql

Optimize Database Tables

wp --path=/home/[user]/apps/[site] --allow-root db optimize

Repair Database

wp --path=/home/[user]/apps/[site] --allow-root db repair

Check Database Size

wp --path=/home/[user]/apps/[site] --allow-root db size

Run a SQL Query

wp --path=/home/[user]/apps/[site] --allow-root db query "SELECT * FROM wp_users;"

Search and Replace URL (Dry Run First)

wp --path=/home/[user]/apps/[site] --allow-root search-replace 'http://old.com' 'https://new.com' --dry-run
wp --path=/home/[user]/apps/[site] --allow-root search-replace 'http://old.com' 'https://new.com'

Always run the dry-run version of search-replace first to preview what will change before applying it.

Section 7: Options & Settings

Read and update WordPress options directly — useful for fixing site URL issues, changing the blog name, or inspecting stored settings.

Get Site URL and Home URL

wp --path=/home/[user]/apps/[site] --allow-root option get siteurl
wp --path=/home/[user]/apps/[site] --allow-root option get home

Update Site URL

wp --path=/home/[user]/apps/[site] --allow-root option update siteurl 'https://newdomain.com'

Update Home URL

wp --path=/home/[user]/apps/[site] --allow-root option update home 'https://newdomain.com'

Get / Update Blog Name

wp --path=/home/[user]/apps/[site] --allow-root option get blogname
wp --path=/home/[user]/apps/[site] --allow-root option update blogname "My Blog"

List All Options

wp --path=/home/[user]/apps/[site] --allow-root option list

Section 8: Cache & Transients

Flush the WordPress object cache and remove transients to resolve stale data issues or after making configuration changes.

Flush Object Cache

wp --path=/home/[user]/apps/[site] --allow-root cache flush

Delete All Transients

wp --path=/home/[user]/apps/[site] --allow-root transient delete --all

Delete Expired Transients Only

wp --path=/home/[user]/apps/[site] --allow-root transient delete --expired

Section 9: Posts & Media

List and manage posts, pages, and media files. The media regenerate command is useful after changing image sizes or switching themes.

List All Posts

wp --path=/home/[user]/apps/[site] --allow-root post list

List Pages Only

wp --path=/home/[user]/apps/[site] --allow-root post list --post_type=page

Delete a Post

wp --path=/home/[user]/apps/[site] --allow-root post delete 123

Regenerate All Thumbnails

wp --path=/home/[user]/apps/[site] --allow-root media regenerate --yes

List Media Files

wp --path=/home/[user]/apps/[site] --allow-root media list

Section 10: Permalinks & Cron

Flush rewrite rules to fix 404 errors after permalink changes, and manage WordPress scheduled events (WP-Cron).

Flush Permalinks / Rewrite Rules

wp --path=/home/[user]/apps/[site] --allow-root rewrite flush

List Scheduled Cron Events

wp --path=/home/[user]/apps/[site] --allow-root cron event list

Run All Due Cron Events Manually

wp --path=/home/[user]/apps/[site] --allow-root cron event run --due-now

Delete a Cron Event

wp --path=/home/[user]/apps/[site] --allow-root cron event delete wp_scheduled_delete

Section 11: Maintenance Mode

Enable maintenance mode before performing updates or migrations so visitors see a maintenance page instead of a broken site.

Enable Maintenance Mode

wp --path=/home/[user]/apps/[site] --allow-root maintenance-mode activate

Disable Maintenance Mode

wp --path=/home/[user]/apps/[site] --allow-root maintenance-mode deactivate

Check Maintenance Mode Status

wp --path=/home/[user]/apps/[site] --allow-root maintenance-mode status

Section 12: Full Backup Before Any Update

Always back up both the database and the site files before running updates, migrations, or destructive operations.

Run these backup commands before making any changes to your WordPress site. A complete backup includes both the database and all site files.

Backup Database

wp --path=/home/[user]/apps/[site] --allow-root db export /home/[user]/backup_before_update.sql

Backup Site Files

tar -czf /home/[user]/cloudstick_backup_$(date +%F).tar.gz /home/[user]/apps/[site]

Section 13: WP-CLI Info & Update

Check the installed WP-CLI version and keep it up to date to ensure compatibility with the latest WordPress releases.

Check WP-CLI Version

wp --allow-root cli version

Check Full WP-CLI Info

wp --allow-root cli info

Update WP-CLI Itself

wp --allow-root cli update
Was this page helpful?
Share this article:
© 2026 CloudStick. All rights reserved.

We use cookies to improve your experience

CloudStick uses cookies to personalise content, analyse traffic and keep you signed in. Cookie Policy · Terms of Service

Manage cookies