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

> Run WP Toolkit tasks from the command line over SSH, such as listing, updating and securing WordPress sites.

Source: https://helpcenter.ruachost.com/wordpress/wp-toolkit/managing-wordpress-from-the-command-line-with-the-cpanel-wp-toolkit/

The **WP Toolkit** in cPanel includes a command‑line utility (`wp-toolkit`) that allows you to perform WordPress administrative tasks directly from the terminal. This is especially useful for developers and system administrators who prefer automation or need to manage multiple WordPress sites efficiently.

## Why Use the Command Line?

- Faster than navigating through the cPanel interface.
- Automate repetitive tasks with scripts or cron jobs.
- Manage multiple WordPress installations at once.
- Access advanced features not always available in the GUI.

## Common Tasks with `wp-toolkit`

### 1. View Help

Displays available commands and options.

```
wp-toolkit --help
```

### 2. List WordPress Installations

```
wp-toolkit --list
```

Shows all WordPress sites managed by WP Toolkit, including paths, versions, and URLs.

### 3. Display Installation Information

```
wp-toolkit --info -instance-id X
```

Replace `X` with the installation ID. Outputs details such as:

- Installation path
- Website URL
- WordPress version
- Admin email
- Security status
- Installed plugins and themes

### 4. Manage Plugins and Themes with Sets

You can group plugins and themes into **sets** for easier deployment.

- Add a plugin to the cache:

  ```
  wp-toolkit --plugins -operation add -source-url https://downloads.wordpress.org/plugin/hello-dolly.1.7.2.zip
  ```
- Add a theme to the cache:

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

- Create a set:

```
wp-toolkit --sets -operation add -name Basic
```

- Install a set on a WordPress site:

```
wp-toolkit --sets -operation install -set-id 7 -instance-id X
```

### 5. Configure Smart Updates

```
wp-toolkit --smart-update -operation enable -instance-id X
```

Enables Smart Updates, which test updates on a cloned site before applying them live.

### 6. Back Up and Restore

- Back up:

```
wp-toolkit --backup -operation backup -instance-id X
```

Creates a `.tar.gz` backup file.

- Restore:

```
wp-toolkit --backup -operation restore -instance-id X -filename backupfile.tar.gz
```

### 7. Reset Administrator Password

```
wp-toolkit --site-admin-reset-password -admin-login username -instance-id X
```

Generates a new password for the specified admin account.

### 8. Automate with Cron Jobs

Example: Daily backup at 2:15 AM

```
15 2 * * * /usr/local/bin/wp-toolkit --backup -operation backup -instance-id X >/dev/null 2>&1
```

> **Note:**
- You must run `wp-toolkit` as the **root user**.
- Basic Linux command‑line knowledge is recommended.
- Always test commands on a staging site before applying them to production.
