WordPress WP-CLI Complete Command Reference
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/wpVerify Installation
wp --allow-root cli version
wp --allow-root cli infoSection 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 versionCheck for Available Updates
wp --path=/home/[user]/apps/[site] --allow-root core check-updateUpdate WordPress Core
wp --path=/home/[user]/apps/[site] --allow-root core updateUpdate Database After Core Update
wp --path=/home/[user]/apps/[site] --allow-root core update-dbVerify Core File Integrity (Check for Tampering)
wp --path=/home/[user]/apps/[site] --allow-root core verify-checksumsDownload Fresh WordPress (Force Overwrite)
wp --path=/home/[user]/apps/[site] --allow-root core download --forceUpdate 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 --allSection 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 listList Users with Specific Fields
wp --path=/home/[user]/apps/[site] --allow-root user list --fields=ID,user_login,user_email,rolesGet Details of a User
wp --path=/home/[user]/apps/[site] --allow-root user get 1Update 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=1Send Password Reset Email
wp --path=/home/[user]/apps/[site] --allow-root user reset-password 1Section 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 listInstall a Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin install woocommerceInstall and Activate a Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin install woocommerce --activateActivate a Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin activate woocommerceDeactivate a Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin deactivate woocommerceDeactivate ALL Plugins
wp --path=/home/[user]/apps/[site] --allow-root plugin deactivate --allUpdate Specific Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin update woocommerceUpdate All Plugins
wp --path=/home/[user]/apps/[site] --allow-root plugin update --allDelete a Plugin
wp --path=/home/[user]/apps/[site] --allow-root plugin delete woocommerceCheck Plugin Status
wp --path=/home/[user]/apps/[site] --allow-root plugin status woocommerceSection 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 listInstall a Theme
wp --path=/home/[user]/apps/[site] --allow-root theme install astraInstall and Activate a Theme
wp --path=/home/[user]/apps/[site] --allow-root theme install astra --activateActivate a Theme
wp --path=/home/[user]/apps/[site] --allow-root theme activate astraUpdate Specific Theme
wp --path=/home/[user]/apps/[site] --allow-root theme update astraUpdate All Themes
wp --path=/home/[user]/apps/[site] --allow-root theme update --allDelete a Theme
wp --path=/home/[user]/apps/[site] --allow-root theme delete twentytwentySection 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).sqlImport Database
wp --path=/home/[user]/apps/[site] --allow-root db import /home/[user]/backup.sqlOptimize Database Tables
wp --path=/home/[user]/apps/[site] --allow-root db optimizeRepair Database
wp --path=/home/[user]/apps/[site] --allow-root db repairCheck Database Size
wp --path=/home/[user]/apps/[site] --allow-root db sizeRun 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 homeUpdate 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 listSection 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 flushDelete All Transients
wp --path=/home/[user]/apps/[site] --allow-root transient delete --allDelete Expired Transients Only
wp --path=/home/[user]/apps/[site] --allow-root transient delete --expiredSection 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 listList Pages Only
wp --path=/home/[user]/apps/[site] --allow-root post list --post_type=pageDelete a Post
wp --path=/home/[user]/apps/[site] --allow-root post delete 123Regenerate All Thumbnails
wp --path=/home/[user]/apps/[site] --allow-root media regenerate --yesList Media Files
wp --path=/home/[user]/apps/[site] --allow-root media listSection 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 flushList Scheduled Cron Events
wp --path=/home/[user]/apps/[site] --allow-root cron event listRun All Due Cron Events Manually
wp --path=/home/[user]/apps/[site] --allow-root cron event run --due-nowDelete a Cron Event
wp --path=/home/[user]/apps/[site] --allow-root cron event delete wp_scheduled_deleteSection 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 activateDisable Maintenance Mode
wp --path=/home/[user]/apps/[site] --allow-root maintenance-mode deactivateCheck Maintenance Mode Status
wp --path=/home/[user]/apps/[site] --allow-root maintenance-mode statusSection 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.sqlBackup 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 versionCheck Full WP-CLI Info
wp --allow-root cli infoUpdate WP-CLI Itself
wp --allow-root cli update