October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

Getting Started With WP-CLI: Manage WordPress From the Terminal

A practical WP-CLI guide covering requirements, Phar installation, first commands, updates, plugins, themes, databases, SSH, scripting, and troubleshooting.
Length9 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

WP-CLI is WordPress’s official command-line interface. After installing it on a server or development machine, you can inspect a site, install and update plugins, manage themes, edit users and posts, run database operations, and administer multisite without opening the WordPress dashboard. The practical pattern is simple: connect to the machine, change to the directory containing wp-config.php, then run a wp command.

What WP-CLI is and why it matters

WP-CLI replaces many point-and-click administration tasks with commands you can repeat, audit, and automate. The project describes it as a way to perform WordPress administration without a browser, covering core software, plugins, themes, databases, users, posts, multisite networks, and cron events.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A command runs against the WordPress installation that WP-CLI discovers from your current working directory. That makes the first operational rule important: change into the site directory before running site commands. On a typical Linux server, that might be /var/www/example; on a local project it could be the folder containing your development checkout.

WP-CLI is useful for both one-off maintenance and repeatable operations. A single command can list every plugin on a site, while a shell script can apply the same controlled update process to dozens of installations. It also works when the administration dashboard is slow, unavailable, or unsuitable for a remote server.

Requirements and supported environments

Minimum software versions

The WP-CLI project lists stable version 2.12.0 (2026). Its stated minimums are PHP 7.2.24 or later and WordPress 4.9 or later. Older WordPress versions may have degraded functionality even if a command appears to start.

Check both versions on the machine where commands will run. PHP must be available to the shell, and the account running WP-CLI must be able to read the WordPress files and, for changes, write to the relevant directories and database.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operating systems and installation choices

The normal target is a Unix-like environment: Linux, macOS, FreeBSD, or Cygwin. Windows support is limited, so verify the exact hosting or local setup before adopting a Windows-only workflow. The project documents four practical installation routes:

  • Phar: the recommended choice for most users and the simplest standalone download.
  • Composer: useful when WP-CLI belongs to a PHP project or needs project/global dependency management.
  • Homebrew: a convenient package route on macOS and compatible environments.
  • Docker: appropriate when you want a containerized, reproducible toolchain.

WP-CLI itself does not require special hardware. For a remote site, you do need an account with shell access—usually SSH—and a hosting plan that permits it.

Install WP-CLI with the Phar build

The Phar build is the normal starting point. Run these commands in a directory where you can download a file, then install the executable somewhere on your shell’s PATH.

  1. Download the Phar.
    Download wp-cli.phar or run:
    curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  2. Inspect the downloaded file and environment.
    php wp-cli.phar --info

    This reports the WP-CLI and PHP information before you change permissions or move the file.

  3. Make the Phar executable.
    chmod +x wp-cli.phar
  4. Move it onto your path.
    sudo mv wp-cli.phar /usr/local/bin/wp

    Use a different directory if your system’s executable path is elsewhere. The account needs permission to write to the destination.

  5. Confirm the installed command.
    wp --info

    Run this without the filename. If it prints WP-CLI and PHP details, your shell can find the executable.

Composer, Homebrew, and Docker follow different package-management conventions, but the verification step is the same: run wp --info and confirm that the reported PHP version meets the project minimum.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run your first commands

Start in the WordPress directory

Once WP-CLI is installed, move to the directory containing the site:

cd /var/www/example
wp --info
wp core version
wp help plugin install

wp --info checks the executable and runtime. wp core version asks the installation for its WordPress version. wp help plugin install displays the built-in documentation for that subcommand, including available arguments and flags. WP-CLI provides built-in help for every command, so use it before relying on an unfamiliar option.

When WP-CLI cannot find WordPress

If the command says it cannot find WordPress, you are usually in the wrong directory or pointing at the wrong installation. Change to the directory that contains the site’s configuration and core files, or use the command’s path/global path option where appropriate. On a server with several sites, explicitly identifying the path is safer than assuming the shell’s current directory.

Core command families to learn first

WP-CLI groups related actions under a command namespace. The following map covers the tasks most administrators perform.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Command family Typical uses Example
wp core Download, install, inspect, update, update the database, verify checksums, and manage core-related multisite operations. wp core version
wp plugin List, install, activate, deactivate, update, and delete plugins. wp plugin list
wp theme List, install, activate, update, and otherwise manage themes. wp theme list
wp db Export, import, and perform database-oriented operations. 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 events manually. wp cron event list
wp cache Inspect or flush the object cache. wp cache flush

Most commands print human-readable output by default and can be combined with scripting options when you need machine-readable results. Read the command help first, especially before using a delete, update, import, or flush operation.

Install, update, and verify WordPress core

Download and install a new site

From an empty document root, download WordPress and run the installer:

wp core download
wp core install --url=https://example.com --title="Example" --admin_user=admin [email protected]

The install command requires the database connection details to be available through the site configuration or the options you provide in your environment. Choose a strong administrator password and protect the resulting account; do not place a reusable password in a shell history or a script committed to source control.

Inspect and update an existing site

wp core version
wp core check-update
wp core update
wp core update-db
wp core verify-checksums

wp core check-update reports whether an update is available. wp core update applies the core update, while wp core update-db brings the database schema into line after a core update when required. wp core verify-checksums compares core files with published checksums and can reveal unexpected modifications.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Take a tested backup before mutating operations. A core update can expose incompatibilities in plugins, themes, PHP extensions, or custom code, so stage the change when the site is important and have a rollback path.

Manage plugins and themes from the terminal

Plugins

wp plugin list
wp plugin install hello-dolly --activate
wp plugin deactivate hello-dolly
wp plugin update --all
wp plugin delete hello-dolly

Use wp plugin list before changing anything so you know which plugins are active, inactive, or missing files. Install and activate in separate steps when you want to verify compatibility first. Updating all plugins is convenient, but a staged update—one plugin or a controlled group at a time—makes failures easier to identify.

Themes

wp theme list
wp theme install twentytwentyfour
wp theme activate twentytwentyfour
wp theme update --all

Activating a theme changes the public presentation immediately. Confirm that the theme exists and that you have a recovery plan before switching on a production site. Keep an inactive fallback theme installed when your maintenance policy allows it.

Users, posts, databases, cron, and cache

Users and content

Use wp user to create accounts, update user fields, and reset passwords. Use wp post to list content or perform controlled bulk creation, edits, and deletion. For bulk changes, first run a read-only listing and export the affected IDs so you can review exactly what a later command will modify.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Database export, import, and search-replace

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

An export gives you a restorable SQL file before a risky migration. The search-and-replace command is especially useful when moving a site between domains; start with --dry-run, review the reported changes, and keep a fresh database backup. Serialized data requires a tool that understands WordPress serialization; WP-CLI’s search-replace command is designed for that job, but you should still test the migration on a copy first.

Cron and object cache

wp cron event list
wp cron event run --all
wp cache flush

Inspect scheduled events before running them manually. Running every due event can trigger outbound mail, imports, or other application work immediately. Flushing the object cache removes cached objects and may temporarily increase database load; use it to resolve stale-cache issues, not as a routine substitute for diagnosing the underlying cause.

Use WP-CLI over SSH

WP-CLI can administer a remote site once you have SSH access. WordPress.com’s developer documentation demonstrates the basic pattern: connect with SSH, change to the WordPress directory, and run a command such as wp post list.

ssh [email protected]
cd /var/www/example
wp --info
wp post list

The SSH account must have a compatible PHP executable and sufficient filesystem and database permissions. Hosting environments sometimes expose several PHP versions; invoke the version selected by the host if the default binary is too old. For production, use key-based SSH authentication where available, restrict account permissions to what maintenance requires, and avoid putting secrets directly in commands that may be recorded in shell history.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If remote administration is a requirement, choose SSH-enabled WordPress hosting or a managed WordPress plan that explicitly permits WP-CLI. A hosting control panel login alone does not guarantee shell access.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Turn one-off commands into safe scripts

WP-CLI commands are ordinary terminal programs, so they can be composed into shell scripts, scheduled jobs, and deployment pipelines. A robust script should:

  • Change to a known site directory instead of depending on the caller’s current directory.
  • Stop on errors and log output so a failed update is visible.
  • Run read-only checks first, such as wp core version and wp plugin list.
  • Create or verify a backup before database, content, or update operations.
  • Use a staging copy for major updates and migrations.
  • Keep credentials outside source control and avoid exposing them in process listings.

Separate inspection from mutation. For example, list posts and export their IDs before issuing a bulk delete; run search-replace with --dry-run before writing; and verify checksums after a core update. These habits make automation repeatable without turning a typo into an irreversible outage.

Choose the right execution and installation workflow

Decision Best fit What changes operationally
Local or remote Local for development and testing; remote over SSH for a live server. Remote work depends on shell access, server PHP, permissions, and the correct site path.
One-off command or script One-off for inspection or an isolated fix; scripts for repeatable maintenance. Scripts need error handling, logging, backups, and protected credentials.
Single site or multisite Single-site commands for one installation; wp site and multisite-aware options for networks. Network-wide actions can affect many sites, so confirm scope before mutating data.
Read-only or mutating Start read-only when diagnosing or planning. Updates, deletes, imports, cache flushes, and search-replace require a rollback plan.
Phar, Composer, Homebrew, or Docker Phar for most standalone users; Composer for PHP projects; Homebrew for package-managed desktops; Docker for a containerized toolchain. The installation mechanism differs, but wp --info remains the basic verification.

Troubleshoot common failures

“Error: This does not seem to be a WordPress installation.”

Check pwd, list the directory contents, and confirm that you are at the WordPress root rather than one level above or inside wp-content. Then rerun wp core version. If the server hosts several sites, specify the intended path using the command’s path option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“wp: command not found”

The Phar may not be on PATH, or your shell may not have reloaded its command hash. Run the executable by its full path, confirm that /usr/local/bin (or your chosen directory) is on PATH, and rerun wp --info.

PHP version or permission errors

Run php --version and compare it with the WP-CLI minimum of PHP 7.2.24. On managed servers, select the host-provided PHP binary that meets the requirement. For permission failures, verify that the SSH account can read WordPress files, write where an update needs to write, and connect to the configured database.

A command changes the wrong site

Stop immediately, check the current directory and the site URL reported by WordPress, and avoid relying on a shared shell session’s previous location. Explicit paths and a printed preflight check in scripts prevent cross-site mistakes.

A plugin or theme update breaks the site

Use the command-line listing to identify the recently changed component, deactivate it if you can still reach WordPress, and restore the tested backup when necessary. Test the update on staging before repeating it in production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.