WP-CLI Commands Every VPS WordPress Owner Should Know in 2026

If you run WordPress on a VPS, the dashboard is not always the fastest way to get work done. A plugin update that stalls in the browser, a site move that leaves old URLs in the database, or a locked-out admin account can each eat an afternoon. The WP-CLI commands for WordPress in this guide handle those jobs from the terminal in seconds. You need a small set you trust, plus the habit of backing up before you change anything.

WP-CLI is a command-line tool for WordPress. It talks to the same database and files as your site, but it skips the admin screens and browser timeouts. On a VPS you already have SSH access, so the tool fits how the server works. Run it from your site root, the folder that holds wp-config.php, and it finds your install on its own.

Before You Run Anything: Safety Checks

WP-CLI is fast, and that speed cuts both ways. A search-replace across every table takes one line, and so does a mistake. Before any command that writes to the database, take a backup: wp db export ~/backup-before-changes.sql writes a full dump you can restore with wp db import if the change goes wrong. Keep that file outside the public web folder.

Run WP-CLI as the same user that owns the WordPress files, usually www-data on Ubuntu, for example with sudo -u www-data wp .... Running it as root can create files your web server cannot read later, which leads to upload errors and broken updates. Start every session with wp --info and wp core version. If either one complains that the folder does not look like a WordPress install, you are in the wrong directory. Add --path=/var/www/your-site or change into the site root first. The guide on using WP-CLI to manage WordPress faster from the terminal walks through the first setup in more detail if you have not installed it yet.

WP-CLI Commands for WordPress: The Everyday Essentials

The commands you will use most often answer a question or list a state, not change things. wp core check-update tells you whether a new WordPress version is waiting. wp plugin list shows every plugin, its version, its status, and whether an update exists. wp theme list does the same for themes. wp option get siteurl and wp option get home show the two URLs WordPress uses, which is the first thing to check when a site redirects to the wrong address after a move.

For reading content, wp post list --post_type=post --fields=ID,post_title,post_status prints a compact table of posts you can scan faster than the admin list. wp user list --fields=ID,user_login,user_email,roles does the same for accounts. These read-only commands are safe to run any time, and they are a good way to learn the tool before you trust it with changes.

Updates, Plugins, and Themes Without the Dashboard

Updating from the terminal avoids the browser timeouts that hit large sites on small VPS plans. wp core update installs the latest WordPress release, then wp core update-db runs any database upgrades the new version needs.

For plugins, wp plugin update --all updates everything with an available release, while wp plugin update akismet updates one plugin by its slug. Updating one plugin at a time is how you find the plugin that breaks a site after an update. Before a batch update, list what will change with wp plugin list --update=available. The same pattern works for themes: wp theme update --all or wp theme update twentytwentyfive.

wp plugin install wordfence --activate downloads a plugin from the WordPress directory and turns it on. wp plugin deactivate wordfence turns it off without deleting its settings, which is useful when a plugin causes a white screen and you cannot reach the admin area at all. Deactivating it from the terminal often brings the site back in under a minute. Removing a plugin is wp plugin delete wordfence, which also removes its files.

Search, Replace, and Fix a Moved Site

Moving WordPress to a new domain or from HTTP to HTTPS leaves the old address inside posts, widgets, and settings. The database stores some of those values in serialised form, where a plain text find-and-replace in a SQL dump would corrupt the data. The wp-cli search-replace command handles serialised values correctly, which is why it is the standard tool for this job.

Always start with a dry run: wp search-replace 'http://old-domain.com' 'https://new-domain.com' --dry-run. The output shows how many replacements it would make in each table, and nothing changes. If a table shows far more replacements than you expected, stop and check why before you run it for real. When the dry run looks right, run the same command without --dry-run and add --all-tables so it covers tables added by plugins. Then clear the caches, or visitors will keep seeing pages built from the old URLs: wp cache flush and wp transient delete --all. The migration guide on moving WordPress from shared hosting to a VPS covers the full move, including the DNS switch and the search-replace step in order.

Database Commands That Save a Broken Site

The wp-cli database commands are the ones you reach for when the site shows an error establishing a database connection, or when the database has grown so large that backups take too long. Start with wp db check, which reports whether each table is healthy, and wp db size --tables, which lists the largest tables. On many sites the biggest tables are post revisions and transients, not the posts themselves.

wp db export ~/site-backup.sql is the backup to use before any database work, and wp db import ~/site-backup.sql restores it. For cleanup, wp db optimize reclaims space after you delete old data, and wp db repair attempts to fix a table that wp db check flagged as crashed. Run them after a backup anyway. wp transient delete --expired removes only transients that have already expired, which is safer than deleting all of them on a live site. The guide on cleaning up WordPress revisions and transients that slow down your site shows how to measure the bloat first, and the guide on backing up MySQL databases automatically with mysqldump and cron shows how to schedule exports so a backup exists even when you forget to take one by hand.

Users, Cron, and Cache: The Quiet Maintenance Jobs

A locked-out admin is a common VPS support request, and WP-CLI fixes it without a password reset email that may never arrive. wp user list --role=administrator shows who has admin access. wp user update 1 --user_pass='a-strong-new-password' sets a new password for the user with ID 1. Change it again from the dashboard once you are in. wp user create editor-name [email protected] --role=editor adds a new account in one line.

WordPress cron is not a real cron. It only runs when someone visits the site, so scheduled posts and plugin jobs can sit unrun on a quiet site. wp cron event list shows the scheduled jobs and their next run time. wp cron event run --due-now runs every job that is due. On a VPS you can call that command from a real system cron job every few minutes, which keeps scheduled tasks on time. The walkthrough on running WordPress cron properly on a VPS instead of fake visits explains the setup and why the visit-triggered default falls behind.

Cache commands round out the routine. wp cache flush clears the object cache after a change the site does not seem to pick up. wp rewrite flush rebuilds the rewrite rules when a permalink change returns 404 errors. Each is a one-line fix for a problem that otherwise looks like a broken site.

When WP-CLI Says No: Common Errors and Fixes

Most WP-CLI errors point at the environment, not the command. “This does not seem to be a WordPress installation” means you are in the wrong folder or the --path is wrong. “Error establishing a database connection” means WordPress cannot reach MySQL, so check that MySQL is running and check the credentials in wp-config.php. A PHP memory error during a large search-replace usually means the job needs more memory, so run it with php -d memory_limit=512M $(which wp) search-replace ....

When a single plugin update breaks the site, work backwards. Deactivate the plugin you just updated, clear the cache, and load the site. If it returns, you found the cause. Check the plugin changelog and the site error log before you update it again. That habit, update one thing, check the site, then move on, is what turns WP-CLI from a fast way to break things into a fast way to fix them.

Start with the read-only commands and the backup habit. WP-CLI turns the terminal into the quickest way to run WordPress.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.