How to Install WP-CLI on a linux

About WP-CLI

WP-CLI will be particularly useful if you are a WordPress developer, System Administrator or run a business built on WordPress. WP-CLI is an awesome command line tool for WordPress. It has a lot of commands that can help us installing plugins/themes, add posts, updating WordPress Core, taking backups, querying databases, import/export data quickly and easily. This command line tool will greatly help you do more in less time.

Download WP-CLI

First Connect your server through SSH. wp-cli.org recommended to install WP-CLI is by downloading the Phar file. The latest version WP-CLI installation file is available here. You can download by using wget or curl. For Example:

wp-cli-1

Check if it works

Enter the following command to check if it works or not.

wp-cli-2

Creating executable files

Enter the following command to make it executable.

wp-cli-3

Move WP-CLI.PHAR File

We can move wp-cli.phar file to /usr/local/bin and rename it to wp. This will help us use the WP-CLI commands by just typing ‘wp’ at the start of the commands. Type wp –info to check the status.

wp-cli-4

WP-CLI Update

In future, you can update wp cli by entering the following command to update.

wp-cli-5For more information about wp-cli installation click here.

wp-cli bash completion

The bash completion feature of WP-CLI allows you to see all the available commands on the fly.

Download the bash script in your home directory:

Edit the .bashrc file

Edit the file.bashrc so that it is loaded by the shell every time you log in. Open the file and add the following line in the editor:

Run the following command to reload the bash profile:

That’s it. Bash completion is now enabled. To test it, type wp theme (include the trailing space) and press Tab twice. You will see the list of available commands with wp theme again on the prompt.

Vijayan J

Thanks for stopping by guys! I’m Vijayan and Techpulse is my beloved brainchild.
Currently working as a PHP developer in a digital marketing start-up, I’m overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across…
‘What separates successful people from unsuccessful people is the former’s ability to execute’.
Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!