> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing WordPress from the command line with the cPanel WP Toolkit

> Learn to use cPanel's wp-toolkit for WordPress tasks via command line and cron jobs, including backups and plugin management.

This article describes how to use the *wp-toolkit* program to manage WordPress sites from the command line, as well as how to use it in cron jobs to automate tasks.

<Warning>
  **Important**

  The *wp-toolkit* program is part of the cPanel WP Toolkit. However, it is currently only available for accounts with root access.
</Warning>

## About wp-toolkit

It is often quicker and easier to do many tasks at the command line, and WordPress administration is no exception. You can use the *wp-toolkit* program to back up and restore WordPress sites, install plugins and themes, reset the administrator password, and more. Additionally, you can run *wp-toolkit* in cron jobs to automate tasks.

<Tip>
  Because *wp-toolkit* is a command-line tool, it helps if you already have some basic familiarity with the Linux command-line environment. If you have never worked in the Linux command-line environment before, you can learn the basics by reading [this article](/docs/introduction-linux-commands).
</Tip>

## Using wp-toolkit at the command line

*wp-toolkit* has many commands, and the rest of this article is only an introduction to its capabilities. However, to view the *wp-toolkit* online help at any time, type the following command:

```bash theme={null}
wp-toolkit --help
```

Alternatively, to view the online help for a specific *wp-toolkit* subcommand, add the **-command** option. For example, to view the online help for the *wp-toolkit --list* command, type the following command:

```bash theme={null}
wp-toolkit --help -command list
```

<Note>
  You must run *wp-toolkit* as the root user.
</Note>

### Listing WordPress installations

To view a listing of the WordPress sites managed by WP Toolkit on your account, type the following command:

```bash theme={null}
wp-toolkit --list
```

A listing appears that resembles the following output:

```text theme={null}
ID   Installation Path  Owner ID         State  Hidden                 Website URL                    Name  Version
 1     /public_html/wp         2  Outdated PHP   false      https://example.com/wp              My Website    5.8.1
 2    /public_html/wp2         2  Outdated PHP   false     https://example.com/wp2        My Other Website    5.8.1
```

<Note>
  The **ID** column shows the *instance ID* for the WordPress installation. Make a note of these ID numbers, because you need them to run many of the commands in *wp-toolkit*.
</Note>

### Displaying WordPress installation information

To list information about a WordPress installation managed by WP Toolkit, type the following command. Replace ***X*** with the instance ID of the installation that you want to check:

```bash theme={null}
wp-toolkit --info -instance-id X
```

This command displays information about the site, such as:

* Installation path.
* Website URL.
* WordPress version installed.
* Administrator's e-mail address.
* Automatic update policy.
* Security status.
* SSL/TLS configuration.
* List of all of the plugins and themes installed.

### Using sets to manage plugins and themes

*wp-toolkit* uses the concept of a *set* to manage plugins and themes. A set is a custom collection of themes and plugins that you can install on your sites. For example, you could create a "Basic" set that contains plugins and themes you want available on all of your sites, and an "Extras" set that contains additional plugins you may not want to install on every site.

Let's create a simple set that contains one plugin and one theme. The first step is to upload the plugin and theme to the *wp-toolkit* cache. To upload a plugin, you need the URL to the plugin's *zip* file. You can obtain this from the *wordpress.org* site. The following command demonstrates how to upload the "Hello Dolly" plugin to the cache:

```bash theme={null}
wp-toolkit --plugins -operation add -source-url https://downloads.wordpress.org/plugin/hello-dolly.1.7.2.zip
```

Next, we upload a theme. To upload a theme, you need the URL to the theme's *zip* file, which you can obtain from the *wordpress.org* site. The following command demonstrates how to upload the "Twenty Twenty" theme to the cache:

```bash theme={null}
wp-toolkit --themes -operation add -source-url https://downloads.wordpress.org/theme/twentytwenty.1.8.zip
```

Now we are ready to create a set. Let's call the set "Basic". To create this set, we run the following command:

```bash theme={null}
wp-toolkit --sets -operation add -name Basic
```

After we create the set, *wp-toolkit* shows the set's ID number, which we need for subsequent commands. In this case, the set ID is **7**:

```text theme={null}
ID     Name                            Owner GUID
 7    Basic  9475252e-1234-4321-4444-4923d4521ae7
```

We are ready to add the plugin and theme to the set. To do this, we need the set ID, the plugin's slug, and the theme's slug. The slug is usually the basename of the zip file. For example, the slug of *hello-dolly.1.7.2.zip* is *hello-dolly*, and the slug of *twentytwenty.1.8.zip* is *twentytwenty*.

Here is the command to add the plugin to the set:

```bash theme={null}
wp-toolkit --sets -operation add-plugin -set-id 7 -plugin-slug hello-dolly
```

The command to add the theme to the set is similar:

```bash theme={null}
wp-toolkit --sets -operation add-theme -set-id 7 -theme-slug twentytwenty
```

We now have a "Basic" set that contains the "Hello Dolly" plugin and "Twenty Twenty" theme. To confirm this, run the following command:

```bash theme={null}
wp-toolkit --sets -operation info -set-id 7
```

*wp-toolkit* lists the plugins and themes that belong to the set.

To install this set on a WordPress installation, we run the following command, replacing ***X*** with the instance ID of the installation on which we want to install the set:

```bash theme={null}
wp-toolkit --sets -operation install -set-id 7 -instance-id X
```

This is a simple example to give you an idea of how sets work. Typically, a set contains multiple plugins and themes to make site configuration easier.

### Configuring Smart Updates

With *wp-toolkit*, you can easily configure Smart Updates for your WordPress sites.

<Note>
  The Smart Updates feature enables you to test an update without actually affecting the site. It does this by creating a full clone of the website, running a number of preliminary checks, updating the cloned website, and running the checks again to see if the update breaks anything. The results include before-and-after screenshots that you can compare to make an informed decision about whether or not to proceed with the update on your "live" site.
</Note>

To check the Smart Updates status of a WordPress installation, type the following command. Replace ***X*** with the instance ID of the installation to check:

```bash theme={null}
wp-toolkit --smart-update -operation status -instance-id X
```

To enable Smart Updates, type the following command. Replace ***X*** with the instance ID of the installation:

```bash theme={null}
wp-toolkit --smart-update -operation enable -instance-id X
```

To disable Smart Updates, type the following command. Replace ***X*** with the instance ID of the installation:

```bash theme={null}
wp-toolkit --smart-update -operation disable -instance-id X
```

### Backing up and restoring WordPress content

You can quickly and easily back up and restore site content using *wp-toolkit*. All files and the database (which includes posts, pages, comments, and categories ) are exported to a compressed\_.tar.gz\_ file. This backup file is located in the */home/username/wordpress-backups* directory, where ***username*** represents your account username.

To back up a WordPress installation, type the following command. Replace ***X*** with the instance ID of the installation to back up:

```bash theme={null}
wp-toolkit --backup -operation backup -instance-id X
```

When this command finishes, you can transfer the *.tar.gz* file to a safe location.

To restore a backup, type the following command. Replace ***X*** with the instance ID of the installation, and replace ***filename*** with the name of the backup file to restore (do not include the full path, specify only the filename):

```bash theme={null}
wp-toolkit --backup -operation restore -instance-id X -filename filename
```

<Tip>
  To obtain a list of backup files available for restoration, type the following command. Replace ***X*** with the instance ID of the installation:
</Tip>

```bash theme={null}
wp-toolkit --backup -operation list -instance-id X
```

### Resetting the administrator password

You can use *wp-toolkit* to reset the WordPress administrator password. To do this, type the following command. Replace ***username*** with the login name of the administrator, and replace ***X*** with the instance ID of the installation:

```bash theme={null}
wp-toolkit --site-admin-reset-password -admin-login username -instance-id X
```

After you run this command, *wp-toolkit* displays the new, randomly generated password for the specified administrator.

<Tip>
  If there is only one administrator for the specified site, you can omit the **-admin-login** option.
</Tip>

## Using wp-toolkit in a cron job

By combining *wp-toolkit*'s functionality with cron jobs, you can automatically do administrative tasks that are time consuming and repetitive from the  graphical administration interface.

For example, the following cron line demonstrates how to back up a WordPress site automatically every day at 2:15 AM by using *wp-toolkit*:

```text theme={null}
15 2 * * * /usr/local/bin/wp-toolkit --backup -operation backup -instance-id id >/dev/null 2>&1
```

## More information

For more information about the *wp-toolkit* program, please visit [https://docs.cpanel.net/knowledge-base/cpanel-developed-plugins/wp-toolkit-command-line-interface/](https://docs.cpanel.net/knowledge-base/cpanel-developed-plugins/wp-toolkit-command-line-interface/).

## Related articles

* [Installing WordPress with the cPanel WP Toolkit](/docs/installing-wordpress-with-the-cpanel-wordpress-toolkit)
* [Managing WordPress with the cPanel WP Toolkit](/docs/managing-wordpress-with-the-cpanel-wordpress-toolkit)
* [Managing multiple sites with the cPanel WP Toolkit](/docs/managing-multiple-sites-with-the-cpanel-wordpress-toolkit)
* [Managing plugins with the cPanel WP Toolkit](/docs/managing-plugins-with-the-cpanel-wordpress-toolkit)
* [Managing themes with the cPanel WP Toolkit](/docs/managing-themes-with-the-cpanel-wordpress-toolkit)
* [Staging WordPress with the cPanel WP Toolkit](/docs/staging-wordpress-with-the-cpanel-wordpress-toolkit)
