WP-CLI is WordPress’s official command-line interface. It lets you inspect and administer a site without opening the dashboard: install and update core, plugins, and themes; work with users, posts, databases, cron, caches, and multisite networks; and turn repeatable maintenance into scripts. The practical path is to install the Phar package, change to your WordPress directory, verify the environment, and begin with read-only commands before making changes.
Antihost offers managed WordPress hosting with free migration, one-click staging and a 14-day free trial.
What WP-CLI is and why terminal administration matters
WP-CLI is the command line interface for WordPress. Instead of navigating wp-admin, you type a command in a shell and receive text output. That makes routine work faster when you already have server access, and it makes the same operation repeatable across staging, production, or a group of sites.
As an Amazon Associate I earn from qualifying purchases.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The interface covers the main WordPress administration areas: core files and database updates, plugins, themes, users, posts, databases, scheduled events, object caches, and multisite networks. A command can be run interactively once, saved in a shell script for later, or executed after connecting to a remote server over SSH.
Terminal access does not bypass WordPress permissions or server security. WP-CLI runs as the operating-system user who invokes it and loads the target installation, so file ownership, PHP extensions, database credentials, and the current working directory all affect the result.
#1 Best Overall
Requirements and supported environments
The WP-CLI project lists stable version 2.12.0 (2026). Its minimum versions are PHP 7.2.24 or later and WordPress 4.9 or later. Older WordPress releases may still respond to some commands, but the project warns that functionality can be degraded.
- Operating system: Unix-like systems such as Linux, macOS, FreeBSD, and Cygwin are the normal targets.
- Windows: support is limited; a compatible Unix-like layer such as Cygwin may be needed, and hosting-provider documentation should take precedence.
- PHP CLI: the
phpexecutable must be available in the shell and meet the minimum version. - WordPress access: you need the site files and a user that can read or modify them, plus database access for commands that touch the database.
- Remote work: an SSH account and a host that permits command-line PHP are required before WP-CLI can administer a remote site.
Managed WordPress hosting with SSH enabled can satisfy the server prerequisite, but providers differ in whether they expose the required PHP version, permit long-running commands, or restrict database access. Confirm those details with the host before planning automation.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Choose an installation method
| Method | Best fit | What to know |
|---|---|---|
| Phar download | Most individual servers and workstations | The official handbook recommends the Phar build for most users. It is a single file that can be placed on your PATH. |
| Composer | Projects that already manage PHP dependencies | Useful when WP-CLI belongs to a project or a team-wide dependency workflow. Composer installation is documented by the project. |
| Homebrew | macOS or other systems using Homebrew | Convenient package management, with updates handled through the package manager. |
| Docker | Containerized development and CI | Keeps the CLI environment reproducible, but the container still needs access to the WordPress files and database. |
For a first installation on a Unix-like machine, use the Phar sequence below. If your host supplies a preinstalled wp command, check its version and path before replacing it.
Install WP-CLI step by step
- Download the Phar file. Run:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar - Inspect the downloaded file and PHP environment.
php wp-cli.phar --info
This prints WP-CLI and PHP details without changing the site. - Make the file executable.
chmod +x wp-cli.phar - Put it on your executable path. A common system-wide location is:
sudo mv wp-cli.phar /usr/local/bin/wp
Use a user-owned directory instead if you do not have administrative privileges. - Confirm the command is available.
wp --info
Check that the reported WP-CLI version, PHP binary, and PHP version are the ones you expect.
If php wp-cli.phar --info fails, fix PHP first rather than continuing. A shell can contain several PHP installations, and the PHP used by your web server is not necessarily the PHP used by the command line.
Run your first commands in the correct WordPress directory
WP-CLI normally searches for WordPress from the directory in which you run the command. Change into the installation directory before issuing site commands:
Rank #2
cd /var/www/example
wp --info
wp core version
wp help plugin install
The first command confirms the CLI environment. wp core version proves that WP-CLI found a WordPress installation. The help command demonstrates that built-in documentation is available for individual commands and subcommands.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteIf WP-CLI says it cannot find WordPress, verify that the directory contains the installation’s files and that your account can read them. You can also point to a site explicitly with the global --path=/var/www/example parameter. On multisite, --url=https://example.com selects the site context for commands that support it.
Core command families you will use most
| Family | Typical tasks | Example |
|---|---|---|
wp core |
Download, install, update, update the database, inspect versions, verify checksums, and manage multisite-related core work | wp core version |
wp plugin |
List, install, activate, deactivate, update, and delete plugins | wp plugin list |
wp theme |
List, install, activate, update, and manage themes | wp theme list |
wp db |
Export and import databases and perform operations such as search-replace | wp db export backup.sql |
wp user |
Create users, update accounts, and reset passwords | wp user list |
wp post |
List, create, edit, or delete content in bulk | wp post list |
wp site |
Manage sites in a multisite network | wp site list |
wp cron |
Inspect scheduled events and run due events | wp cron event list |
wp cache |
Inspect or flush the WordPress object cache | wp cache flush |
Inspect a site before changing it
Start with commands that only read information. They establish the target, reveal versions, and give you a record of the current state.
wp core version
wp plugin list
wp theme list
wp user list
wp post list --post_type=post --posts_per_page=20
wp cron event list
Use wp help <command> whenever you need the accepted arguments, output formats, or a less common subcommand. For example, wp help db search-replace shows the options for a URL or domain migration before you run it.
Install and maintain plugins and themes
Plugins
List installed plugins first, then install or update only what you intend:
Rank #3
wp plugin list
wp plugin install plugin-slug --activate
wp plugin deactivate plugin-slug
wp plugin update plugin-slug
wp plugin update --all
wp plugin delete plugin-slug
Replace plugin-slug with the plugin’s actual directory slug. Activating, deleting, or updating code changes the running site; take a backup and schedule the work for a maintenance window when the change could affect visitors.
Themes
wp theme list
wp theme install theme-slug
wp theme activate theme-slug
wp theme update --all
Keep a known-good theme available before activating a new one. On a multisite network, confirm whether you are managing one site or network-wide theme availability.
Use the core lifecycle commands safely
The core command family supports the normal download, installation, update, database-migration, and integrity-check sequence:
wp core download
wp core install --url=https://example.com --title="Example" --admin_user=admin [email protected]
wp core version
wp core check-update
wp core update
wp core update-db
wp core verify-checksums
New installation
wp core download places WordPress files in the target location. wp core install creates the initial site using the database settings available to the installation and the values you supply. Protect the administrator account and use a mailbox you control for --admin_email.
Free tools Windows power users keep installed
One-click scans. No signup required.
Updating an existing site
Run wp core check-update first to see whether an update is available. Back up files and the database, test on staging when possible, then run wp core update. If the update requires schema changes, run wp core update-db. Finish with wp core verify-checksums to detect unexpected changes to WordPress core files; a checksum result does not validate plugin or theme code.
Rank #4
Back up and edit the database
Database commands are powerful because they can alter every matching row. Export a backup before an import, search-replace, or bulk content operation, and store the backup somewhere separate from the live database.
wp db export before-change.sql
wp db import before-change.sql
wp db search-replace 'old.example.com' 'new.example.com'
Search-replace is commonly used during domain migrations. Review the command’s help for table-scope, dry-run, and serialization options before applying it to production. Confirm the old and new values, and ensure the replacement is appropriate for every table you select.
Manage users, posts, cron, cache, and multisite
Users
wp user create editor [email protected] --role=editor
wp user list
wp user update 123 [email protected]
wp user reset-password 123
Use numeric IDs or the identifiers shown by wp user list. Treat password-reset output and temporary credentials as sensitive information.
Recommended Free Tools
Posts and other content
wp post list --post_type=post
wp post create --post_title="Terminal note" --post_status=draft
wp post update 123 --post_status=publish
wp post delete 123
For bulk work, first generate a list and inspect it, then run the mutating command against the confirmed IDs. Deletion may be irreversible without a database backup.
Cron and cache
wp cron event list
wp cron event run --due-now
wp cache flush
Running due events manually is useful when diagnosing a stalled schedule, but it can trigger mail, imports, or other jobs immediately. Flushing the object cache removes cached objects; it does not replace a page-cache purge performed by a reverse proxy or hosting platform.
Best Value
Multisite
wp site list
wp --url=https://subsite.example.com plugin list
Always identify whether a command is for the network or one site. The wp site family handles network administration, while the --url context targets a particular site for commands that support it.
Use WP-CLI over SSH
Yes, WP-CLI can administer a remote site over SSH. First obtain an SSH account from the server or hosting provider. Then connect, change to the WordPress directory, and run the same commands you would run locally:
ssh [email protected]
cd /var/www/example
wp --info
wp post list
The remote shell must have access to the site files, the correct PHP CLI binary, and the database credentials used by wp-config.php. If the host places the site elsewhere, use its documented path or pass --path. SSH keys are preferable to passwords for repeatable administration, and production keys should be restricted to the tasks they need to perform.
Remote execution is especially useful for maintenance scripts and scheduled jobs. Keep commands observable: log the host, path, date, WP-CLI version, and command output, while excluding passwords and other secrets.
Turn one-off commands into safe scripts
A shell script can update several sites or perform a consistent inspection, but automation magnifies mistakes. Separate read-only discovery from mutation and stop when a prerequisite fails.
#!/usr/bin/env bash
set -euo pipefail
cd /var/www/example
wp core version
wp plugin list --format=table
wp db export "backup-$(date +%F).sql"
wp core check-update
- Use an explicit
cdor--path; never assume the shell started in the site directory. - Quote URLs, titles, paths, and values that contain spaces or shell metacharacters.
- Export a database before destructive operations and verify that the backup file was created.
- Test scripts on staging and use a maintenance window for core, plugin, theme, and schema changes.
- Record exit codes and output, but redact passwords, salts, tokens, and personally identifiable data.
Local versus remote, inspection versus mutation
| Decision | Safer starting point | Why it matters |
|---|---|---|
| Local or remote execution | Local for development; SSH for a hosted site | The command is similar, but remote work depends on SSH, server permissions, PHP CLI, and the correct path. |
| One-off command or script | One-off while learning; script after verification | Scripts improve repeatability but can apply an error to many sites. |
| Single site or multisite | Confirm the site context first | Network-level and site-level operations have different scope. |
| Read-only or mutating | Read-only inspection first | Version and list commands reveal the target before a change is made. |
| Phar or package-managed install | Phar for a straightforward server setup | Composer, Homebrew, or Docker may fit an existing project or deployment standard better. |
Troubleshoot the common failures
| Symptom | Likely cause | Check or fix |
|---|---|---|
| “This does not seem to be a WordPress installation.” | You are in the wrong directory or the files are unreadable. | Change to the directory containing wp-config.php and WordPress files, or add --path=/full/path. Check ownership and permissions. |
wp: command not found |
The Phar is not on PATH. |
Run it by full path, move it to a directory on PATH, or update your shell’s PATH and start a new shell. |
| PHP version or extension error | The CLI PHP differs from the web-server PHP or is below 7.2.24. | Review wp --info, select the host’s supported PHP binary, and install required extensions through the server’s normal package process. |
| Permission denied while updating | The shell user cannot write WordPress files or the database user lacks privileges. | Use the deployment account intended by the host; correct ownership rather than broadly granting write access. |
| Checksum verification reports differences | Core files were modified, replaced, or damaged. | Compare the files with a trusted deployment record, investigate before overwriting, and remember that checksums cover WordPress core, not plugins or themes. |
| Remote command finds no site | SSH landed in the account’s home directory or a different PHP environment. | Run pwd, locate the site, cd there, and repeat wp --info. |
A practical first-session checklist
- Verify PHP and install WP-CLI 2.12.0 or the current supported release for your environment.
- Change to the WordPress directory and run
wp --infoandwp core version. - Use
wp plugin list,wp theme list, andwp user listto inspect the site. - Read command-specific help before using an unfamiliar option.
- Export the database before any update, search-replace, import, deletion, or bulk edit.
- Test a mutating command on staging, then run it during a controlled maintenance window.
- For remote work, confirm SSH access, the absolute site path, PHP CLI version, and the account’s permissions.
Once these habits are in place, WP-CLI becomes a predictable administration layer: inspect first, identify the exact site context, back up before mutation, and automate only the commands you have already verified manually.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




