Disclosure: Some links in this post are affiliate links. If you purchase through them, I may earn a commission at no additional cost to you. All recommendations are based on research and publicly available information.

If you’ve ever wished you could update plugins, run database queries, or manage users without loading the WordPress admin dashboard, WP-CLI is the tool you need. This WP-CLI tutorial covers everything from installation to advanced automation — whether you’re managing a single blog or a multisite network with dozens of sites.

WP-CLI (WordPress Command Line Interface) lets you control virtually every aspect of a WordPress installation from the terminal. No clicking through menus. No waiting for pages to load. One command does what would take a dozen clicks in the admin panel.

What Is WP-CLI and Why Use It?

WP-CLI is an open-source command-line tool maintained by the WordPress community. It’s been shipping continuously since 2011, and in 2026 it’s more capable than ever — with support for AI agent integration via the Model Context Protocol (MCP) and the Abilities API.

Here’s what you can do with WP-CLI that’s tedious or slow in the admin:

  • Install, activate, and update plugins and themes across an entire network with one command
  • Export and import databases without phpMyAdmin
  • Run search-replace across your database — essential for migrating sites between domains
  • Create, edit, and delete users in bulk
  • Manage multisite networks — add sites, enable themes, configure settings
  • Schedule cron jobs for automated maintenance
  • Flush cache, regenerate thumbnails, rotate security keys — all from the terminal

According to the official WP-CLI documentation: “Anything you can do in the WordPress admin, you can do from the terminal. Install and update plugins, import content, create users, run search-replace across a database, rotate keys, manage multisite networks.”

Step 1: How to Install WP-CLI

Most managed WordPress hosts come with WP-CLI pre-installed. If you’re on a VPS or dedicated server, you’ll need to install it yourself.

Check if WP-CLI Is Already Installed

Before installing, check whether your hosting environment already has WP-CLI:

wp --info

If you see version information, you’re good to go. If you get “command not found,” proceed with installation.

Install WP-CLI on a Linux Server or VPS

The standard installation takes about 30 seconds:

# Download the Phar file
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Make it executable and move to PATH
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

# Verify installation
wp --info

WP-CLI Support by Hosting Provider

Most hosts in 2026 support WP-CLI out of the box. Here’s how the major providers stack up:

Provider WP-CLI Pre-Installed SSH Access Best For
Cloudways ✅ Yes ✅ Via SSH Keys Managed cloud with 1-click WP-CLI app management
InterServer ✅ Yes (standard web hosting plans) ✅ Yes Budget-friendly with price-lock guarantee
SiteGround ✅ Yes ✅ Via Site Tools → SSH Keys Manager Managed WordPress with built-in staging and WP-CLI
ScalaHosting ✅ Yes (SPanel) ✅ Yes Managed VPS with SPanel and SSH terminal

All four providers above include WP-CLI as part of their standard hosting packages. If you’re shopping for a host that supports command-line WordPress management, any of them will work.

Step 2: Essential WP-CLI Commands for Daily Use

Once WP-CLI is installed and you’ve SSH’d into your server, navigate to your WordPress root directory (usually public_html or www):

cd /var/www/your-site

Manage Plugins

The wp plugin command family handles everything plugin-related:

# List all plugins with status
wp plugin list

# Install and activate a plugin
wp plugin install wordfence --activate

# Update all plugins
wp plugin update --all

# Deactivate a specific plugin
wp plugin deactivate akismet

# Delete a plugin (files + data)
wp plugin delete hello-dolly

Pro tip: Use wp plugin update --all --dry-run first to see what would be updated without actually running the update. This is a safe way to check before executing.

Manage Themes

# List active and installed themes
wp theme list

# Install and activate a theme
wp theme install twentytwentyfour --activate

# Update all themes
wp theme update --all

# Switch to a different theme
wp theme activate twentytwentyfive

Manage WordPress Core

# Check current version
wp core version

# Update WordPress to the latest version
wp core update

# Update the database after a core update
wp core update-db

# Verify core file integrity
wp core verify-checksums

The verify-checksums command is especially useful after a suspected hack — it compares every core file against the official WordPress checksums and flags anything that’s been modified.

Step 3: Database Management with WP-CLI

This is where WP-CLI really shines. Database operations that would take 10+ clicks in phpMyAdmin take one command.

# Create a database backup
wp db export backups/2026-07-07-backup.sql

# Optimize all database tables
wp db optimize

# Repair corrupted tables
wp db repair

# Run search-replace (critical for migrations)
wp search-replace 'https://oldsite.com' 'https://newsite.com' --all-tables

# Check database size
wp db size --tables

Search-Replace: The Migration Superpower

The wp search-replace command is arguably WP-CLI’s most valuable feature. When you move a WordPress site from one domain to another, serialized data in the database can break if you use a simple find-and-replace. WP-CLI handles serialized data correctly.

Here’s the migration pattern most developers use:

# 1. Export the database
wp db export staging-backup.sql

# 2. Replace the old domain with the new one
wp search-replace 'https://staging.mysite.com' 'https://mysite.com' --all-tables

# 3. Flush the cache
wp cache flush

# 4. Verify nothing broke
wp db check

Step 4: User Management

Creating and managing users from the command line is faster than the admin interface, especially when setting up client sites or adding editors in bulk.

# Create a new user
wp user create johndoe johndoe@example.com --role=editor --display_name="John Doe"

# List all users
wp user list

# Update user role
wp user set-role johndoe author

# Reset password
wp user reset-password johndoe

# Delete a user and reassign their posts
wp user delete johndoe --reassign=admin

Step 5: Automating Maintenance with Shell Scripts

Here’s where you get the most value from WP-CLI — bundling commands into scripts that run automatically.

Weekly Maintenance Script

Save this as maintenance.sh and run it from cron to handle routine upkeep:

#!/bin/bash
# WordPress Weekly Maintenance
# Run: bash maintenance.sh

SITE_PATH="/var/www/yoursite"
BACKUP_PATH="/backups/wordpress"

cd $SITE_PATH

echo "📦 Backing up database..."
wp db export "$BACKUP_PATH/backup-$(date +%Y%m%d).sql"

echo "🔄 Updating core..."
wp core update
wp core update-db

echo "🔌 Updating plugins..."
wp plugin update --all

echo "🎨 Updating themes..."
wp theme update --all

echo "🧹 Cleaning up..."
wp transient delete --all
wp cache flush

echo "✅ Maintenance complete!"

Set it up as a weekly cron job:

# Run every Sunday at 3 AM
0 3 * * 0 bash /path/to/maintenance.sh

Real-Time Maintenance Operations Compared

Here’s how common maintenance tasks compare between the admin dashboard and WP-CLI:

Task Admin Dashboard WP-CLI Time Saved
Update 10 plugins Select each → click Update → confirm 10 times wp plugin update --all ~5 minutes
Create 5 user accounts Users → Add New × 5, fill forms wp user create × 5 in a loop ~8 minutes
Database backup + optimize phpMyAdmin: select DB → export → run optimize wp db export + wp db optimize ~3 minutes
Migrate site to new domain Export SQL → manual search-replace → re-import wp search-replace + wp db export ~15 minutes
Multisite: add 5 new sites Network Admin → Sites → Add New × 5 wp site create × 5 in a script ~10 minutes

Step 6: Multisite Network Management

If you’re running a WordPress Multisite network, WP-CLI is practically essential. Managing 20+ sites through the Network Admin is slow — WP-CLI turns it into a batch operation.

# List all sites in the network
wp site list

# Create a new site
wp site create --slug=clientsite --title="Client Site" --email=client@example.com

# Activate a plugin across the entire network
wp plugin activate wordfence --network

# Run a command on every site
wp site list --field=url | xargs -I{} wp --url={} plugin update --all

Step 7: Troubleshooting Common WP-CLI Issues

Even experienced users hit snags. Here are the most common problems and how to fix them.

“Error: Can’t find a WordPress installation”

You’re running WP-CLI from the wrong directory. Navigate to the WordPress root (where wp-config.php lives):

# Find where WordPress is installed
find / -name "wp-config.php" -type f 2>/dev/null

# Navigate there
cd /path/to/wordpress

“Error: YIKES — Failed to connect to MySQL”

WP-CLI can’t reach the database. This usually means your wp-config.php has the wrong credentials or the MySQL server isn’t running:

# Check MySQL status
systemctl status mysql
# or
service mysql status

# Test database connection
wp db check

“Permission denied” when running WP-CLI

You’re probably trying to run WP-CLI as a user that doesn’t have write access to the WordPress files:

# Run as the web server user
sudo -u www-data wp plugin update --all

WP-CLI Cheat Sheet: Quick Reference

Here’s a condensed reference of the most useful commands for day-to-day management:

Core Management

  • wp core version — Check WordPress version
  • wp core update — Update WordPress core
  • wp core verify-checksums — Verify core file integrity
  • wp core update-db — Update database schema

Plugin Management

  • wp plugin list — List all plugins with status
  • wp plugin install <slug> --activate — Install and activate
  • wp plugin update --all — Update all plugins
  • wp plugin deactivate <slug> — Deactivate a plugin
  • wp plugin delete <slug> — Remove plugin files and data

Theme Management

  • wp theme list — List themes
  • wp theme activate <slug> — Switch active theme
  • wp theme update --all — Update all themes

Database Operations

  • wp db export <file>.sql — Export database
  • wp db import <file>.sql — Import database
  • wp db optimize — Optimize tables
  • wp db repair — Repair corrupted tables
  • wp search-replace <old> <new> --all-tables — Search and replace

User Management

  • wp user create <login> <email> --role=<role> — Create user
  • wp user list — List all users
  • wp user delete <user> --reassign=<user> — Delete and reassign posts

Multisite

  • wp site list — List all sites
  • wp site create --slug=<slug> — Create a new site
  • wp site archive <url> — Archive a site

FAQ

Do I need a VPS to use WP-CLI?

No. Most shared hosting providers — including InterServer, SiteGround, and Cloudways — include WP-CLI access with their standard hosting plans. You just need SSH access enabled from your hosting control panel.

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

Most WP-CLI commands are safe for production use. Commands that modify data (like wp db import, wp search-replace, wp plugin delete) should be tested on a staging environment first. Always back up your database before running destructive operations.

Can WP-CLI break my site?

Only if you run commands without understanding what they do. The safest approach: always use --dry-run flags when available, keep database backups before destructive operations, and test on a staging site first. See the WordPress maintenance guide for a full safety checklist.

What’s the difference between WP-CLI and the WordPress admin?

The admin dashboard is a GUI — great for visual tasks and beginners. WP-CLI is a command-line tool — faster for repetitive tasks, essential for automation, and required for operations like bulk search-replace or multisite network management. Most developers use both.

Does WP-CLI work with managed WordPress hosting?

Most managed hosts support WP-CLI. Cloudways has it pre-installed on all servers. ScalaHosting’s SPanel includes a terminal. SiteGround provides SSH access through Site Tools.

How do I update WP-CLI itself?

# Check current version
wp cli version

# Update to latest
wp cli update

# Check for available update without applying it
wp cli check-update

Final Thoughts

WP-CLI turns a WordPress site from something you manage through a browser into something you can script, automate, and integrate into deployment pipelines. The learning curve is shallow — you can start with wp plugin update --all and work up to full maintenance scripts from there.

If your current host doesn’t support WP-CLI or SSH access, consider switching to one that does. Cloudways, InterServer, SiteGround, and ScalaHosting all include WP-CLI and SSH with their hosting plans. Every minute you spend learning these commands saves you hours of clicking through the admin dashboard.