WP-CLI-manage WordPress from the command line
WP-CLI is the command-line interface for WordPress. Install it on your VPS, then manage plugins, themes, users, databases,
On this page
WP-CLI lets you manage WordPress entirely from the terminal. It's faster than the admin panel for bulk operations-update all plugins with one command, reset a password without logging in, or run a database search-replace in seconds.
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/wp
Verify: wp --version
WP-CLI commands must be run from the WordPress installation directory, or you specify the path: wp --path=/var/www/html command
Run WP-CLI as the user that owns the WordPress files (e.g., www-data on Ubuntu): sudo -u www-data wp plugin list. Running as root can change file ownership.
WordPress core commands
# Check WordPress version
wp core version
# Update WordPress core
wp core update
# Verify WordPress files are intact
wp core verify-checksums
# Download a fresh WordPress
wp core download
Plugin management
# List all plugins with status
wp plugin list
# Update all plugins
wp plugin update --all
# Activate a plugin
wp plugin activate plugin-name
# Deactivate a plugin
wp plugin deactivate plugin-name
# Install a plugin from the repository
wp plugin install woocommerce --activate
Database commands
# Export database
wp db export backup.sql
# Import database
wp db import backup.sql
# Run a MySQL query
wp db query "SELECT * FROM wp_options WHERE option_name='siteurl'"
# Optimize database tables
wp db optimize
# Check database for errors
wp db check
User management
# List users
wp user list
# Reset a user's password
wp user update admin --user_pass=NewSecurePassword123
# Create a new admin user
wp user create newadmin admin@example.com --role=administrator --user_pass=SecurePass
# Delete a user
wp user delete 5 --reassign=1
Search-replace
The most useful WP-CLI command for s-replaces URLs throughout the database including serialized data:
# Dry run first (shows what would change without making changes)
wp search-replace 'https://old-domain.com','https://new-domain.com' --dry-run
# Run the replacement
wp search-replace 'https://old-domain.com','https://new-domain.com' --all-tables
Need managed WordPress hosting?
Run WordPress on UnderHost managed hosting with performance tuning, SSL, backups, security guidance, and expert support.





















