WordPress Command Line Interface (or, wp-cli ) is installed on all servers at DreamHost. This feature allows you to run WordPress commands from your Shell terminal. For example you can import a database, create a new user, update themes and plugins all using wp-cli.
This article is a quick overview of this service. View the following articles for information on how to create a Shell user and log into your server to run these commands.
Listing available commands
Log in to your server via SSH. Once logged in, make sure you’re in your WordPress site’s directory. In that directory run the following command to print a list of available options:
The following available commands display:
SUBCOMMANDS cache Manage the object cache. cap Manage user capabilities. checksum Verify WordPress core checksums. cli Manage WP-CLI itself. comment Manage comments. config Manage the wp-config.php file core Download, install, update and manage a WordPress install. cron Manage WP-Cron events and schedules. db Perform basic database operations using credentials stored in wp-config.php doctor Diagnose what ails WordPress. eval Execute arbitrary PHP code. eval-file Load and execute a PHP file. export Export WordPress content to a WXR file. find Find WordPress installs on the filesystem. help Get help on WP-CLI, or on a specific command. host-check Check that the WordPress install is still hosted at its internal domain. import Import content from a WXR file. language media Manage attachments. menu List, create, assign, and delete menus. network option Manage options. package Manage WP-CLI packages. plugin Manage plugins. post Manage posts. post-type Manage post types. profile rewrite Manage rewrite rules. role Manage user roles. scaffold Generate code for post types, taxonomies, plugins, child themes, etc. search-replace Search/replace strings in the database. server Launch PHP's built-in web server for this specific WordPress installation. shell Interactive PHP console. sidebar Manage sidebars. site Perform site-wide operations. super-admin Manage super admins on WordPress multisite. taxonomy Manage taxonomies. term Manage terms. theme Manage themes. transient Manage transients. user Manage users. widget Manage sidebar widgets.
Finding more information on a command
To get more information on a specific command, run the --help option. For example:
[server]$ wp plugin --help
This prints a list of available subcommands. For example:
SUBCOMMANDS activate Activate a plugin. deactivate Deactivate a plugin. delete Delete plugin files. get Get a plugin. install Install a plugin. is-installed Check if the plugin is installed. list Get a list of plugins. path Get the path to a plugin or to the plugin directory. search Search the wordpress.org plugin repository. status See the status of one or all plugins. toggle Toggle a plugin's activation state. uninstall Uninstall a plugin. update Update one or more plugins.
You can then combine these with the main command to perform an action. Here is how you’d install a plugin named hello-dolly:
[server]$ wp plugin install hello-dolly Installing Hello Dolly (1.6) Downloading install package from https://downloads.wordpress.org/plugin/hello-dolly.1.6.zip... Unpacking the package... Installing the plugin... Plugin installed successfully.
If you now run ‘wp plugin list’, all of your plugins appear:
[server]$ wp plugin list +--------------------+----------+--------+---------+ | name | status | update | version | +--------------------+----------+--------+---------+ | akismet | inactive | none | 3.1.1 | | dreamobjects | inactive | none | 3.5.2 | | hello-dolly | inactive | none | 1.6 | | hello | inactive | none | 1.6 | | jetpack | active | none | 3.5.3 | | varnish-http-purge | active | none | 3.7.2 | +--------------------+----------+--------+---------+
These popular commands are used most often when debugging:
Deactivating a plugin
[server]$ wp plugin deactivate PLUGIN_NAME
[server]$ wp plugin toggle NAME
Deactivating installed plugins on multisite network
[server]$ wp plugin toggle NAME --network
Deactivating a theme
[server]$ wp theme deactivate THEME_NAME
You must then activate a different theme:
[server]$ wp theme activate THEME_NAME
Changing a password
List all users to view their user ID#:
[server]$ wp user list
Use that user ID# to update their password:
[server]$ wp user update 3 --user_pass=123456
Flushing your cache
Depending on which plugin you’re using, run one of these to flush your cache:
[server]$ wp cache flush
[server]$ wp super-cache flush
Re-updating core files
[server]$ wp core update
Forcing the DB upgrade to run
[server]$ wp core update-db