BlogSecurity

How To Install WP-CLI: Easy Guide

ShreyaShreyaUpdated July 24, 2025 · 7 min read

Share

Install WP-CLI Feature image

Install WP-CLI once, and suddenly you can manage your WordPress website in minutes. Want to update 20 plugins? You can do it in 10 seconds. Want to create dozens of test users? A single command handles it. Trying to access your site files? Now they’re one-liners. Sounds great, right? 

However, a lot of the tutorials online feel like you’re reading a different language. I did the research, tested the install and simplified the steps in this article. I’ll walk you through everything step by step—from installation to your first commands. You’ll be a whiz in minutes. 

TL;DR

Download WP-CLI by running curl -O https://raw.githubusercontent.com/wp-cli/wp-cli/v2.8.1/wp-cli.phar. Then install it, make it executable, and move it to your system path. Additionally, for Windows systems, add the path to your system variables. After that you can use your SSH credentials to connect to your server from the command line.

WP-CLI (WordPress Command Line Interface) is a powerful tool that lets you manage WordPress sites through text commands instead of clicking through admin dashboards. Think of it as a remote control for your WordPress site—you can update plugins, install themes, create users, backup databases, and perform almost any WordPress task by typing simple commands.

install wp-cli to use wp-config

Before you install WP-CLI

We’ll show you how to install WP-CLI. But, first, let’s make sure your system is ready. WP-CLI works alongside your existing WordPress setup. It requires a few basic components to function properly.

  • PHP 7.4 or higher
  • Command-line/terminal access

Install WP-CLI

Now that you’ve confirmed your system meets the requirements, it’s time to install WP-CLI. The process is straightforward—we’ll download the file, test it works, then set it up so you can use it to connect to your WordPress site. 

  1. Download WP-CLI:
Code
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

This downloads the WP-CLI file to your current directory. Don’t worry about the .phar extension—it’s just a PHP file format.

  1. Test that it downloaded correctly:
Code
php wp-cli.phar --info

If it works, you’ll see details like the WP-CLI version and your PHP version. Something like:

  1. Make the file executable:
Code
chmod +x wp-cli.phar

This tells your system that the WP-CLI file is a program it can run, rather than just a regular document.

  1. Move the file:
Code
sudo mv wp-cli.phar /usr/local/bin/wp

You’ll be asked for your password—type it and press Enter. (Your typing won’t show up, but it’s working!)

By moving WP-CLI to /usr/local/bin/, you’re putting it in one of your system’s folders, so when you type wp from anywhere, your system knows exactly where to find it. 

  1. Test the install
Code
wp --info

If you see WP-CLI info again, you’re done! 🎉 You can now run wp commands from anywhere on your system.

Connect to your server

Before you start using WP-CLI to update WordPress, , you have to connect to your server. To use WP-CLI on your live WordPress site, you’ll need to connect to your server via SSH. You’ll need three pieces of information from your hosting provider: your server address (domain or IP), your username, and your password. Most hosting companies include these details in your welcome email or hosting control panel.

  1. Use this command to connect:
Code
ssh username@yourserver.com

Replace username with your actual username and yourserver.com with your server address. For example:

  1. You’ll be prompted for your password. Type it and press Enter. (Your typing won’t show up for security—that’s normal!)

Once connected, you’ll see a command prompt that looks different—this means you’re now controlling your server remotely and can run WP-CLI commands on your actual WordPress site.

Essential WP-CLI Commands You Should Know

After you install WP-CLI, here are some commands you might find useful to navigate it:

Code
cd

Change Directory: This moves you from one folder (directory) to another.
Example: cd applications

Code
ls 

List Files and Folders: Shows everything inside the folder you’re currently in.

Code
pwd 

Print Working Directory: Shows you where you are right now.
Example: pwd might output: /home/master/applications

Code
. 

This Folder: Refers to the current folder.

Code
.. 

Go Up One Folder: Refers to the parent folder (the folder you’re inside).

Code
~ 

Home Folder: Refers to your home directory (the folder you’re in right after you SSH in).

Code
wp plugin update plugin-slug

Replace plugin-slug with the actual plugin slug to update a WordPress plugin

Code
wp theme update theme-slug

Replace theme-slug with the actual theme slug to update theme

Code
wp core update

Update WordPress core

Code
wp plugin install plugin-slug --activate


Install and activate plugin

Code
wp plugin deactivate plugin-slug


Deactivate plugin

Code
wp user create name email@example.com --role=author

Create user

Code
wp user update username --user_pass=newpassword


Change  WordPress passwor

Code
wp db export ../my-database-backup.sql

This creates a .sql file one folder above public_html, named my-database-backup.sql.

Code
cd .. then tar -czf my-site-files-backup.tar.gz public_html

This creates a compressed .tar.gz file containing all your WordPress files.

Code
scp username@server-ip:/path/to/backup-file /path/on/your/mac

Secure copy – copies the backup file to your computer

Code
wp db import ../my-database-backup.sql

Import the database

Code
tar -xzf my-site-files-backup.tar.gz

This command extracts (unpacks) a .tar.gz backup file, which contains a compressed copy of your entire WordPress site.

Code
wp db tables

List all database tables.

Limitations of WP-CLI

While WP-CLI is incredibly powerful, it’s not perfect. It’s not as easy to use as ManageWP or it’s alternatives. Here are the main limitations you’ll encounter.

  • Hosting & environment limitations: WP-CLI may not be available on some shared hosting plans. Budget hosts often disable command-line access entirely. Some servers block certain WP-CLI commands for security reasons, and low PHP memory or timeout settings can cause commands to fail mid-execution.
  • Plugin & theme compatibility: Many plugins don’t support WP-CLI commands unless the developer explicitly added them. You can’t use WP-CLI to manage plugins that don’t expose a WP-CLI interface. Bulk updates (like wp plugin update –all) can break your site if something goes wrong—there’s no built-in rollback. There’s also limited support for managing WooCommerce features (like orders or coupons) unless custom extensions are installed.
  • Functional gaps: No preview or undo for powerful commands like wp search-replace. You can’t upload images directly from your computer to the Media Library via WP-CLI. Visual elements (like menus, widgets, customizer settings) can’t be easily managed. Multisite support exists, but advanced network tasks are still tricky and require manual work.
  • Safety & security concerns: Commands run instantly—there are no confirmation prompts or undo options. One wrong command (like wp db import) can overwrite your entire database. Anyone with SSH access and WP-CLI can make full admin-level changes. It’s easy to break things if you’re not careful or if you skip backups.
  • Operational Limitations: WP-CLI doesn’t log actions unless you set it up manually. There’s no built-in scheduling or automation—you need cron or external scripts. It doesn’t provide usage analytics, change history, or monitoring of what changes were made when.

Final thoughts

WP-CLI transforms how you manage WordPress sites. What used to take hours of clicking through admin panels now happens in seconds. Managing multiple sites becomes effortless, bulk operations become reliable, and you gain the power to automate repetitive tasks that would otherwise eat up your day.

However, it’s important to remember that a small mistake could crash your site. So, we recommend you install a backup plugin like BlogVault. Once you install it, it will automatically take backups of your site daily. If something goes wrong, you can easily restore your site in one click. 

FAQs

What is WP-CLI?

WP-CLI is a command-line interface for WordPress that lets you manage your WordPress sites through text commands instead of clicking through the admin dashboard. You can update plugins, install themes, create users, manage databases, and perform most WordPress tasks faster and more efficiently than through the web interface.

How to create a WP CLI command?

To create a custom WP-CLI command, you need to write a PHP class that extends WP_CLI_Command and register it using WP_CLI::add_command(). Create a plugin or add the code to your theme’s functions.php file. Here’s a basic example:
class My_Custom_Command {
    public function hello( $args, $assoc_args ) {
        WP_CLI::success( ‘Hello World!’ );
    }
}
WP_CLI::add_command( ‘my-command’, ‘My_Custom_Command’ );

What are the requirements for WP CLI?

WP-CLI requires: PHP 7.4 or higher, a web server with WordPress installed, command-line/terminal access to your server, cURL or wget for downloading, and proper file permissions to make files executable and move them to system directories. Shared hosting users need to verify their host allows SSH/command-line access.

Written by
Shreya
Shreya

Shreya has been a writer for as long as she can remember. Now, she writes articles that help WordPress users manage the sites that they're proud of, with little to no coding

Backups built for scale. Restores for the bad day.

No credit card · 14-day money-back guarantee

© 2026 BlogVaultWhatever breaks, you'll get it all back.