Skip to main content

Wordpress: wp cli basic commands

This article will help you to use the WP-CLI (WordPress Command Line Interface) tool to manage your wordpress site

Jay avatar
Written by Jay
Updated over a week ago

WP-CLI is a powerful command-line tool that allows you to manage your WordPress site without needing to log in to the admin dashboard. Whether you're updating plugins, creating users, or clearing the cache, WP-CLI can save you time and streamline your workflow. In this guide, we’ll go over some of the most commonly used WP-CLI commands to help you get started.

  1. Run the command below in the web root directory of your website to list all available WP-CLI commands.

    wp help

  2. Run the command below in the web root directory of your website to list all installed plugins.

    wp plugin list

  3. Run the command below in the web root directory of your website to search for plugins in the WordPress plugin repository.

    wp plugin search smtp

  4. Run the command below in the web root directory of your website to install a plugin from the WordPress plugin repository.

    wp plugin install wp-mail-smtp

  5. Run the command below in the web root directory of your website to activate a specific plugin.

    wp plugin activate wp-mail-smtp

  6. Run the command below in the web root directory of your website to update one or more plugins to their latest versions.

    wp plugin update wp-mail-smtp

  7. Run the command below in the web root directory of your website to update WordPress core to the latest version.

    wp core update

  8. Run the command below in the web root directory of your website to check the currently installed WordPress version.

    wp core version

  9. Run the command below in the web root directory of your website to export your WordPress database to a .sql file.

    wp db export filename.sql

  10. Run the command below in the web root directory of your website to import a .sql file into your WordPress database.

    wp db import latest.sql

  11. Run the command below in the web root directory of your website to list all WordPress users.

    wp user list

  12. Run the command below in the web root directory of your website to delete the user bigscoots and reassign their content to the admin user.

    wp user delete bigscoots --reassign=admin --yes

  13. Run the command below in the web root directory of your website to create a new WordPress user bigscoots with administrator role and specified password.

    wp user create bigscoots noreply@bigscoots.com   --role=administrator --user_pass=Tj86o5pq1Omh

  14. Run the command below in the web root directory of your website to update the password for the WordPress user bigscoots:

    wp user update bigscoots --user_pass="Tj86o5pq1Omh"

Did this answer your question?