How to Install and use WP CLI in the WordPress Website Easily

WP CLI , wp cli tutorial

How to install and use WP CLI v2 in the WordPress website to manage from the command line.

In this post, I’ll tell you what WP CLI is? How to install it on your wordpress project and explain to you how to install it.

Key points

  • What is WP CLI?
  • Requirements of WP-CLI
  • How to install WP CLI?
  • How to use WP CLI
  • Basic WP-CLI Commands

What is WP CLI?

WP CLI is the tool that provides you the several commands to manage your wordpress site from the command line interface and without login from the wp-admin dashboard.

Using the WP CLI you can speed up your development workflow. You install and update WP core, WP themes, and WP plugins via the WP CLI from the command line interface.

WP-CLI will be particularly useful if you are a WordPress developer. This command-line tool will be very helpful to you to do more in less time. Like, updating WordPress and plugins, taking backups, etc.

Requirements of WP-CLI

To install WP-CLI on your WordPress website, make sure you must have a hosting account with SSH access. 

So before installing WP-CLI, please make sure your environment meets the following minimum requirements:

  • PHP 5.4 or later
  • WordPress 3.7 or later.
  • UNIX like environment like Linux.

How to install WP CLI?

In this step, you’ll install the latest version of the WP-CLI tool on your server. So first, Connect to the Root of Your Website Over SSH, I assume that you already have SSH access to your server. To connect the SSH access to your server, you need SSH credentials (i.e. admin username, password, server IP, and port)

You can install the latest version of WP-CLI using the cURL or wget command. The WP-CLI installation file is available as a .phar file and the latest version can be found at:

You can download the Phar file for WP-CLI through curl:

curl -O

This will download and extract the WP-CLI files to your root user directory, So once you have downloaded the file, run the following command to verify that it is working or not:

php wp-cli.phar --info

After runnig the above command you will receive the following output:

OS:     Linux 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64
Shell:  /bin/bash
PHP binary:     /usr/bin/php7.4
PHP version:    7.4.3
php.ini used:   /etc/php/7.4/cli/php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /home/ayo
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0

Next, You will have to set the permissions to make it executable. So to set permissions, enter the following command:

chmod +x wp-cli.phar

To globally use you can move wp-cli.phar to your /usr/local/bin/ folder and rename it to wp. This will help you to use the WP-CLI commands by just typing ‘wp’ at the start of the commands.

To move and rename it, run the following command:

sudo mv wp-cli.phar /usr/local/bin/wp

Now, you will be able to run the various WP CLI command by using the ‘wp’ prefix

So to check WP CLI version, you can run the following command:

wp cli version

And the output will be something like this


WP-CLI 2.4.0

How to use WP CLI

After succesfully install the WP CLI, you can do many things to manage your WordPress website.

If you want to install new theme you just run the following command

wp theme install twentytwentyone

Same as, you can install other themes from the WP Store.

After installing the theme you can activate the theme by following command

wp theme activate twentytwentyone

You can also install the WordPress plugins by running WP CLI command.

wp plugin install wordpress-seo

The above command will install the Yoast SEO plugin on your website. To activate it, we will use the command.

wp plugin activate wordpress-seo

So similarly you can use various WP CLI commands to manage WP Website.

Basic WP-CLI Commands

Here is the basic wordpress command list.

wp theme list
wp theme install twentytwentyone
wp theme activate twentytwentyone
wp theme search twentytwentyone
wp plugin list
wp plugin search seo
wp plugin search seo --page=2
wp plugin install plugin-name
wp plugin activate plugin-name
wp plugin deactivate plugin-name
wp plugin activate --all
wp plugin deactivate --all
wp plugin update plugin - name
wp plugin delete --all
wp post list
wp post delete 100
wp db cli
wp db query "SELECT ID FROM wp_users;"
wp db export
wp db import file.sql

You can find more commands here WP-CLI Commands

I trust this post has been helpful, and now you’ve got a basic idea about the WP CLI and it’s commnds.

More useful article, which may be helpful to you.

MySQL Query to Migrate WordPress Multisite Database
MySQL queries to Change WordPress Website Domain in Database
How to Install WordPress Locally – WordPress Installation Tutorial For Beginner
Share your love

Leave a Reply