Guides 11792 Published by

This quick guide walks you through installing WP‑CLI on a Linux system so you can manage WordPress from the command line instead of using FTP or the admin dashboard. First it lists prerequisites such as sudo access, a working WordPress install, and tools like curl and git, then shows how to download the latest PHAR file directly from GitHub to avoid tampered scripts. After making the file executable and moving it to /usr/local/bin, you verify the installation with wp --info and test it against your site by running commands like wp core version in the WordPress root directory. The article also warns about using old Debian packages that leave you stuck on obsolete versions, offers an alias shortcut for convenience, and concludes by encouraging users to replace mouse‑clicks with quick CLI actions.



Install WP‑CLI on Linux: A Quick, No‑BS Guide

If you’re running WordPress from a server or a local box and hate the “copy‑paste” way to manage themes, plugins, or updates, this is for you. I’ll walk through getting WP‑CLI set up on a typical Linux distro so you can run everything from the command line—no more fiddling with FTP clients.

Why You Should Use WP‑CLI

WP‑CLI lets you handle almost every WordPress task in a few keystrokes. I’ve seen admins who downloaded a plugin, then had to SSH into the server just to bump its version. With CLI you can do that in under ten seconds and keep logs for later.

Prerequisites
  • A Linux machine (Ubuntu/Debian or Fedora/RHEL) with sudo privileges
  • A working WordPress installation, preferably in a subdirectory like /var/www/html/wordpress
  • curl, git, and the usual build tools installed

If you’re missing any of those, install them first:

sudo apt update && sudo apt install -y curl git

or on Fedora:

sudo dnf install -y curl git
Step 1: Grab the Latest Release

WP‑CLI ships as a single PHP file, so you can fetch it directly from GitHub.

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Why this matters: pulling from the official repo guarantees you’re not installing a tampered script that could do anything but run WP‑CLI.

Step 2: Make It Executable
chmod +x wp-cli.phar

This turns the file into a runnable command. If you skip this, every time you try wp it will complain about permissions.

Step 3: Move It to Your PATH
sudo mv wp-cli.phar /usr/local/bin/wp

Now you can call wp from anywhere. I’ve seen people stick the file in their home directory and then have to prefix every command with a path—awkward.

Step 4: Verify the Installation
wp --info

You should see something like:

WP-CLI 2.8.1 (command line interface for WordPress)
WP-Cli/Builds/gh-pages/phar/wp-cli.phar
PHP 7.4.30-0ubuntu0.20.04.3 (cli) * /usr/bin/php
...

If you get an error about PHP or a missing command, double‑check the file location and that you’re using the right PHP binary.

Step 5: Test It Against Your Site

Navigate to your WordPress root:

cd /var/www/html/wordpress

Run a harmless check:

wp core version

It should return the current WordPress release. If it fails, you’re probably not in the right directory or your wp-config.php isn’t readable by the user that runs PHP.

Common Pitfall: Old Debian Packages

I’ve seen users install WP‑CLI via apt-get install wp-cli, only to discover they’re stuck on version 0.14 from 2016, missing newer commands like wp theme update. The simple fix is the steps above—grab the latest PHAR directly.

Optional: Create a Shortcut Alias

If you prefer a shorter command, add this to your .bashrc or .zshrc:

alias wpcmd='wp --path=/var/www/html/wordpress'

Now wpcmd core update does exactly the same thing as the longer form.

Wrap‑Up

You’re now ready to run anything WordPress can do from a terminal. From plugin installs to database backups, WP‑CLI turns tedious clicks into quick commands.