Installing WP-CLI on Ubuntu or Debian makes repetitive WordPress administration faster and less error-prone than clicking through the dashboard for every change. The wp command is especially useful for URL updates, plugin management, cache flushing, database exports, and scripted maintenance.

WP-CLI runs as a PHP command-line application distributed as a single Phar archive. On Ubuntu and Debian, the minimal prerequisites are a working PHP CLI binary, curl to download the Phar, and a pager such as less for some help and output flows.

Installation does not require changing the WordPress web server itself, but the command should still be run from the correct site directory and under an account that has access to the WordPress files. Some subcommands also depend on extra system tools such as mysqldump, so a successful wp --info check confirms the CLI is installed but does not guarantee every maintenance subcommand is ready yet.

Steps to install WP-CLI on Ubuntu or Debian:

  1. Update the package index before installing command-line prerequisites.
    $ sudo apt-get update
  2. Install the required packages for WP-CLI.
    $ sudo apt-get install --yes ca-certificates curl php-cli less
    Reading package lists... Done
    Building dependency tree... Done
    ##### snipped #####

    The verified environment used php8.3 as the active CLI binary on Ubuntu 24.04.

  3. Download the official WP-CLI Phar build.
    $ curl -sSLO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  4. Make the downloaded Phar executable.
    $ chmod +x wp-cli.phar
  5. Move the executable into a directory on the default command path.
    $ sudo mv wp-cli.phar /usr/local/bin/wp
  6. Verify the wp command is available system-wide.
    $ wp --info
    OS:	Linux 6.12.72-linuxkit #1 SMP Wed Feb 25 13:21:17 UTC 2026 aarch64
    Shell:
    PHP binary:	/usr/bin/php8.3
    PHP version:	8.3.6
    php.ini used:	/etc/php/8.3/cli/php.ini
    WP_CLI phar path:	phar:///usr/local/bin/wp
    WP-CLI version:	2.12.0

    If the command is not found, confirm that /usr/local/bin is in the shell PATH and that the file was moved as wp rather than left as wp-cli.phar.

  7. Change into a WordPress document root before running site-specific commands.
    $ cd /var/www/html

    Use the directory that contains /wp-config.php/ for the target site.