For junior web designers, managing WordPress means clicking buttons in the graphical wp-admin browser dashboard. For senior DevOps engineers, agency developers, and sysadmins, managing WordPress happens in the terminal using WP-CLI. WP-CLI (WordPress Command Line Interface) is the official command-line tool for WordPress. It allows you to perform any administrative action — updating core, provisioning databases, generating 100 test dummy posts, or search-replacing millions of serialized URLs — in seconds without opening a web browser!
On Linux or macOS servers with SSH access, install the standalone Phar archive:
# 1. Download Phar archive via curl
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
# 2. Make file executable
chmod +x wp-cli.phar
# 3. Move to global binary path
sudo mv wp-cli.phar /usr/local/bin/wp
# 4. Verify installation
wp --info
| WP-CLI Command | Operational Function & Execution Action |
|---|---|
wp core download |
Downloads fresh WordPress core files into current directory in 3 seconds. |
wp core install |
Executes the 5-minute install script via CLI arguments without web browser! |
wp plugin install <slug> --activate |
Downloads, installs, and activates any repository plugin in a single command. |
wp plugin update --all |
Batch-updates all installed plugins simultaneously. |
wp db export backup.sql |
Instantly dumps the entire MySQL database to an SQL file. |
wp db import backup.sql |
Restores a database dump in seconds with zero PHP timeout risk. |
wp search-replace 'old.com' 'new.com' |
The Developer Magic Wand: Search-replaces URLs while preserving serialized PHP data structures! |
wp post generate --count=50 |
Generates 50 dummy posts with lorem ipsum text for staging theme stress-testing. |
wp user create john john@test.com --role=administrator |
Instantly creates a new administrative user with an auto-generated password. |
wp transient delete --all |
Clears all cached transient options from the wp_options table. |
When migrating a website from localhost:8888 to veewom.com, beginners often attempt to run a raw SQL search-and-replace in phpMyAdmin. This corrupts your website! WordPress stores widget settings, theme mods, and plugin configurations as PHP Serialized Strings (e.g., s:14:"localhost:8888" where 14 represents the character count). If you replace it with veewom.com (10 characters) without updating the length counter to s:10, PHP fails to unserialize the data, breaking theme options!
wp search-replace automatically unpacks serialized arrays, updates string values, recalculates accurate byte lengths, and re-serializes the data safely:
# Safe dry-run to preview changes without modifying database
wp search-replace 'http://localhost/veewom_wp' 'https://veewom.com' --dry-run
# Execute live search-replace across all database tables
wp search-replace 'http://localhost/veewom_wp' 'https://veewom.com'
In DevOps lab exams, students automate full WordPress provisioning with this 5-line bash script:
wp core download
wp config create --dbname=wp_lab --dbuser=root --dbpass=secret
wp db create
wp core install --url=http://localhost/lab --title="Lab Site" --admin_user=admin --admin_email=admin@test.com
Expand your CMS mastery by studying these tightly integrated WordPress development topics:
Install and bootstrap WordPress in 10 seconds via terminal commands.
Automate core, theme, and plugin update sweeps with WP-CLI.
Export databases and search-replace URLs effortlessly with 'wp search-replace'.
Integrate WP-CLI with Git deployment scripts for zero-downtime releases.