WordPress

WP-CLI basics: manage WordPress from the command line

Use WP-CLI over SSH on cPanel hosting: check versions, update core and plugins, manage users, search and replace, export databases and clear caches fast.

IntermediatecPanel hosting3 min read

WP-CLI is the official command-line tool for WordPress. Tasks that take many clicks in the dashboard, such as updating twenty plugins or replacing a domain in every table, take one command. It also works when the dashboard itself is broken.

Before you start

  • SSH access to your cPanel account. You can use cPanel → Advanced → Terminal in the browser, or connect with an SSH client using keys from cPanel → Security → SSH Access.
  • WP-CLI is available as the wp command on MdmHost servers. Check with wp --info.

Go to the site folder

WP-CLI works on the WordPress install in the current folder:

cd ~/public_html

Alternatively add --path=/home/user/public_html to any command.

Check the install

wp core version
wp plugin list
wp theme list

plugin list shows each plugin's status and whether an update is available.

Updates

wp core update
wp core update-db
wp plugin update --all
wp theme update --all

Take a backup first. You can update one plugin with wp plugin update woocommerce, or install a specific version with wp plugin install woocommerce --version=9.0.0 --force to roll back.

Plugins and themes

wp plugin deactivate --all
wp plugin activate classic-editor
wp theme activate twentytwentyfive

Deactivating everything is the fastest way to rule out a plugin conflict when the dashboard is unreachable. Plugins stay installed and keep their settings.

Users and passwords

wp user list --role=administrator
wp user update 1 --user_pass='New-Strong-Pass-2026'
wp user create alex alex@example.com --role=editor

A password set this way appears in your shell history. Clear it with history -c afterwards or use --prompt=user_pass.

Database tasks

wp db export backup.sql
wp db import backup.sql
wp search-replace 'http://example.com' 'https://example.com' --all-tables --dry-run

search-replace handles serialised data correctly, which a plain SQL query does not. Run it with --dry-run first to see how many replacements it would make. Store exports outside public_html so they cannot be downloaded.

Cache and cron

wp cache flush
wp litespeed-purge all
wp cron event list
wp cron event run --due-now

The litespeed-purge command is available when the LiteSpeed Cache plugin is active.

Configuration

wp config list
wp config set WP_DEBUG true --raw
wp option get siteurl

Troubleshooting

  • "This does not seem to be a WordPress installation": you are in the wrong folder; cd to where wp-config.php lives.
  • PHP fatal error on every command: a plugin crashes on load. Add --skip-plugins --skip-themes to the command.
  • Wrong PHP version: WP-CLI uses the command-line PHP. Check with php -v; it can differ from the site's PHP selected in cPanel.
  • Memory errors: run with php -d memory_limit=512M $(which wp) ....

Working with many sites

Resellers often host dozens of WordPress installs in separate cPanel accounts. Within one account you can loop over several installs with a short shell loop, for example running wp plugin update --all --path="$d" for each folder that contains a wp-config.php. Always run wp db export for each site first, and review the output for errors before moving on. Get help on any command with wp help plugin or wp help search-replace.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.