Wp Cli



  1. Wp Clients
  2. Wp Cli Disable Plugin
  3. Wp Cli Debug

The WP-CLI is a tool that enables you to interact with your WordPress site directly by using commands in a text-based interface. It’s also very comprehensive, featuring a wide variety of potential commands. Almost anything you can do on the back end of your site, you can do much faster using the WP-CLI. WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser. Ongoing maintenance is made possible by: The current stable release is version 2.4.0. WP-CLI is the official command line interface for WordPress. You can install and update WordPress core, manage plugins and themes, and much more. For example, this is.

WordPress is one of the most widely used open-source CMS software on the internet. It’s easy to use and even a non-coder can easily set it up and run a website on it.

This doesn’t mean that WordPress is not for developers. WordPress provides a range of tools and documents that help the developers.

One of such tools is WP-CLI, the command line interface for WordPress. With the WP-CLI tools, you can install WordPress or manage and update an existing WordPress installation. You can configure multisite, you can update WordPress core and plugins in the backend server thanks to this command line tool.

The WP-CLI is helpful in debugging issues and managing a WordPress install specially in the case when the WordPress frontend doesn’t work.

You can find a number of reasons to use it. I am going to show you how to install WP-CLI on Ubuntu and other Linux distributions and how to use the basic commands for managing your WordPress install.

Install WP-CLI on Ubuntu and other Linux distributions

I am using Ubuntu 18.04 LTS server hosted on UpCloud. You can get $50 free credits if you use this link for registering for UpCloud servers.

I am using ServerPilot for hosting multiple WordPress install on a single server. If you want to install multiple WordPress on one cloud server, configuration could be complicated. ServerPilot solves this problem and you can install as many WordPress instances as you want in a matter of a few clicks.

Whichever Linux distribution you are using, the installation steps remain the same for all of them.

Step 1: Download the WP-CLI archive file

The WP-CLI is available as .phar (PHP Archive) file. You can download this archive file using Wget or Curl command. I am using wget command here.

You should see an output similar to this:

Step 2: Make the WP-CLI executable

Now that you have download the archive file, you should make this file executable by changing its file permission. You can use the chmod command:

The next step is to move this file into the /user/local/bin. In the Linux directory structure, the bin directory is used for keeping the binaries of the commands you run.

Step 3: Verify that WordPress CLI is working fine

Now that you ‘changed’ the archive file into a command, you should verify that it’s working fine. The easiest way is to check the version of the WP-CLI tool. Use the command below:

If the WP-CLI is ‘installed’ properly, the output should be similar to this:

Activate bash completion for WP-CLI [Optional]

The bash completion feature allows you to auto-complete commands by hitting tab key. This is one of the must know terminal shortcut for any Linux user.

You’ll have to do a little effort to activate bash completion feature for WordPress CLI.

Go to your home directory using the cd command:

Now get the bash completion script:

Your terminal should have a hidden .bashrc file in your home directory. If not, you can create it. What you have to do here is to add the content of the wp-completion.bash file into the .bashrc file. I am going to use the cat command here but you can whatever method you prefer to edit the file.

Now source the .bashrc file so that the changes are taken into effect immediately.

That’s it. Now the wp commands can be auto-completed with the tab key.

Basic WordPress commands you should know

Now that you installed WordPress CLI, it’s time to use it to manage your WordPress install.

To run any command with WP CLI, you must be in the public directory of your WordPress instance installed.

Check the WordPress version

To check the version of your WordPress install, use this command:

Check if any update is available for WordPress core

To check if any WordPress core update is available, use the following command:

If there is update available, the output will notify you of that:

If your WordPress core is the latest version, you should see this message:

Update WordPress via command line

If there is a core update available, you can update the WordPress install using the following command:

The output displays the process:

Clear WordPress cache in command line

A number of WordPress issues are caused by cache. Clearing the cache could ‘fix’ them. You can flush the cache using this command:

Manage WordPress plugins from command line

If you have used WordPress long enough, you know that plugin conflicts often cause trouble. One of the way to handle this issue is to disable the troublesome plugin. If you don’t know which plugin is causing the issue, deactivating all of them and then reactivating them one by one is the way to go.

You can list all the plugins using this command:

The output is in tabular form:

You can deactivate a plugin by using its name. You can see the name in the plugin list command used above.

You can deactivate all plugins in one single command:

Wp Clients

You can activate the plugins the same way. Just use activate instead of deactivate in the above commands.

You can also update individual plugins or all of them together:

More WordPress commands

There are more commands you can use in WP-CLI. You can see the list of plugins with wp plugin list, list of themes with wp theme list. You can install and delete plugins and themes as well. You can manage users and their passwords via WP commands.

It won’t be possible for me to cover all the WP commands. I suggest you refer to the WordPress CLI handbook for finding out the commands you may need.

I hope this tutorial was helpful to you in installing WP-CLI on Linux and you have some basic idea about using the WordPress in command line.

If you have questions or suggestions, please leave a comment below.

Clients
Become a Member for FREE
Become a member to get the regular Linux newsletter (2-4 times a month) and access member-only contents.

Join the conversation.

Below is a listing of all currently available WP-CLI commands with links to documentation on usage and subcommands.

Wp Cli Disable Plugin

Looking to learn more about the internal API of WP-CLI or to contribute to its development? Check out the WP-CLI team’s handbook.

Wp Cli Debug

CommandDescription
wp admin

Open /wp-admin/ in a browser.

wp cache

Adds, removes, fetches, and flushes the WP Object Cache object.

wp cap

Adds, removes, and lists capabilities of a user role.

wp cli

Reviews current WP-CLI info, checks for updates, or views defined aliases.

wp comment

Creates, updates, deletes, and moderates comments.

wp config

Generates and reads the wp-config.php file.

wp core

Downloads, installs, updates, and manages a WordPress installation.

wp cron

Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules.

wp db

Performs basic database operations using credentials stored in wp-config.php.

wp dist-archive

Create a distribution archive based on a project’s .distignore file.

wp embed

Inspects oEmbed providers, clears embed cache, and more.

wp eval

Executes arbitrary PHP code.

wp eval-file

Loads and executes a PHP file.

wp export

Exports WordPress content to a WXR file.

wp find

Find WordPress installations on the filesystem.

wp help

Gets help on WP-CLI, or on a specific command.

wp i18n

Provides internationalization tools for WordPress projects.

wp import

Imports content from a given WXR file.

wp language

Installs, activates, and manages language packs.

wp maintenance-mode

Activates, deactivates or checks the status of the maintenance mode of a site.

wp media

Imports files as attachments, regenerates thumbnails, or lists registered image sizes.

wp menu

Lists, creates, assigns, and deletes the active theme’s navigation menus.

wp network

Perform network-wide operations.

wp option

Retrieves and sets site options, including plugin and WordPress settings.

wp package

Lists, installs, and removes WP-CLI packages.

wp plugin

Manages plugins, including installs, activations, and updates.

wp post

Manages posts, content, and meta.

wp post-type

Retrieves details on the site’s registered post types.

wp profile
wp rewrite

Lists or flushes the site’s rewrite rules, updates the permalink structure.

wp role

Manages user roles, including creating new roles and resetting to defaults.

wp scaffold

Generates code for post types, taxonomies, plugins, child themes, etc.

wp search-replace

Searches/replaces strings in the database.

wp server

Launches PHP’s built-in web server for a specific WordPress installation.

wp shell

Opens an interactive PHP console for running and testing PHP code.

wp sidebar

Lists registered sidebars.

wp site

Creates, deletes, empties, moderates, and lists one or more sites on a multisite installation.

wp super-admin

Lists, adds, or removes super admin users on a multisite installation.

wp taxonomy

Retrieves information about registered taxonomies.

wp term

Manages taxonomy terms and term meta, with create, delete, and list commands.

wp theme

Manages themes, including installs, activations, and updates.

wp transient

Adds, gets, and deletes entries in the WordPress Transient Cache.

wp user

Manages users, along with their roles, capabilities, and meta.

wp widget

Manages widgets, including adding and moving them within sidebars.