WP-CLI is WordPress without the wp-admin screens: backups, updates,
password resets, and search-replaces as single commands. If you maintain a
site, it pays for itself the first week. You’ll need
SSH access to your server
(or a terminal on your own machine for a local site) and PHP available on
the command line — if php --version answers, you’re set.
Check whether your host already ships it
Plenty of hosts — WP Engine, Kinsta, SiteGround, most managed WordPress plans — preinstall WP-CLI. SSH in and ask:
wp --info
If that prints version info, skip straight to running your first command.
If it says command not found, carry on.
Download and install the phar
WP-CLI ships as a single PHP archive file. Download it and confirm it runs:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
Make it runnable from anywhere
Make it executable and move it somewhere on your PATH, so wp works from
any directory:
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
On shared hosting without sudo, use a bin folder in your home directory instead:
mkdir -p ~/bin && mv wp-cli.phar ~/bin/wp
echo 'export PATH=~/bin:$PATH' >> ~/.bashrc && source ~/.bashrc
Run your first command against the site
Change into the directory that holds wp-config.php — WP-CLI reads the
site’s own config, so there’s nothing to connect or configure:
cd /path/to/your/site
wp core version
wp option get siteurl
If those print your WordPress version and your site’s URL, WP-CLI is talking to the right database.
Learn the daily-driver commands
These five cover most maintenance days:
wp db export backup-$(date +%Y-%m-%d).sql
wp plugin list --update=available
wp plugin update --all
wp user update YOUR_USERNAME --user_pass='a-long-new-password'
wp cache flush
That user command deserves a highlight: it’s the calm answer to every
“I’m locked out of my own site” morning, no password-reset email
required. And keep wp cli update in your pocket — WP-CLI updates itself
the same way it updates everything else.
Verify with a harmless dry run
Prove the setup end to end with a command that reads everything and changes nothing:
wp search-replace 'http://example.test' 'http://example.test' --dry-run
A dry run walks every database table and reports what it would change — here, nothing, since both URLs match. If it prints a table report and no errors, WP-CLI is installed, on your PATH, and wired to your site’s database. That’s the whole setup; from here on, the backups and updates you already do by hand become one-liners.