Web Hosting Knowledge Base Web Hosting Knowledge Base
  • Home
Get Started
Web Hosting Knowledge Base Web Hosting Knowledge Base
Get Started
Web Hosting Knowledge Base Web Hosting Knowledge Base
  • Home
loading
  1. Home
  2. cPanel control panel
  3. How to manage WordPress from the command line with the cPanel WordPress Toolkit
Updated on June 18, 2024

cPanel control panel

  • Folder icon closed Folder open iconComplete Guide of log in and log out of cPanel
  • Folder icon closed Folder open iconGetting familiar with the home screen of cPanel
  • Folder icon closed Folder open iconHow to change your cPanel password
  • Folder icon closed Folder open iconHow to change the cPanel language
  • Folder icon closed Folder open iconHow to update contact information and preferences in cPanel
  • Folder icon closed Folder open iconHow to change the cPanel style
  • Folder icon closed Folder open iconHow to change cPanel AutoSSL notifications
  • Folder icon closed Folder open iconcPanel error message: "Your IP address has changed"
  • Folder icon closed Folder open iconThe complete process of User Manager in cPanel
  • Folder icon closed Folder open iconMigrate cPanel accounts from reseller hosting to shared hosting
  • Folder icon closed Folder open iconHow to manage FTP accounts in cPanel
  • Folder icon closed Folder open iconHow to manage backups using cPanel
  • Folder icon closed Folder open iconHow to use Server Rewind to restore files and databases
  • Folder icon closed Folder open iconHow to view disk usage information in cPanel
  • Folder icon closed Folder open iconUsing the cPanel Web Disk Feature
  • Folder icon closed Folder open iconHow to use Server Rewind to restore e-mail
  • Folder icon closed Folder open iconHow to use Git version control in cPanel to install and update a site
  • Folder icon closed Folder open iconHow to reset site content for a managed account
  • Folder icon closed Folder open iconHow to exclude files and directories from cPanel backups
  • Folder icon closed Folder open iconHow to manage e-mail accounts in cPanel
  • Folder icon closed Folder open iconHow to import e-mail accounts and forwarders
  • Folder icon closed Folder open iconHow to change the time zone in webmail
  • Folder icon closed Folder open iconHow to access webmail through cPanel
  • Folder icon closed Folder open iconHow to configure autoresponders in cPanel
  • Folder icon closed Folder open iconHow to import and export webmail contacts
  • Folder icon closed Folder open iconHow to manage mailing lists in cPanel
  • Folder icon closed Folder open iconAccessing webmail clients directly
  • Folder icon closed Folder open iconHow to set up e-mail forwarders
  • Folder icon closed Folder open iconHow to resolve the '550 sender verify failed' error message
  • Folder icon closed Folder open iconExceeding mailbox storage quotas
  • Folder icon closed Folder open iconHow to manage cPanel Mail Exchanger (MX) records
  • Folder icon closed Folder open iconMailing list recipients do not receive list messages
  • Folder icon closed Folder open iconHow to set up DMARC
  • Folder icon closed Folder open iconSynchronizing local clients with webmail calendars and contacts
  • Folder icon closed Folder open iconHow to stop unwanted e-mail using Spam Filters
  • Folder icon closed Folder open iconHow to configure e-mail accounts through webmail
  • Folder icon closed Folder open iconHow to manage e-mail disk usage in cPanel
  • Folder icon closed Folder open iconHow to configure a domain for Google Workspace using cPanel
  • Folder icon closed Folder open iconE-mail messages do not forward to Gmail accounts
  • Folder icon closed Folder open iconHow to filter incoming e-mail messages by IP address
  • Folder icon closed Folder open iconHow to filter unwanted e-mail (spam)
  • Folder icon closed Folder open iconHow to Enable Spam Box
  • Folder icon closed Folder open iconHow to configure e-mail filtering in cPanel
  • Folder icon closed Folder open iconHow to add a Brand Indicators for Message Identification (BIMI) record in cPanel
  • Folder icon closed Folder open iconE-mail messages do not forward to Outlook.com (Hotmail) accounts
  • Folder icon closed Folder open iconHow to manage e-mail deliverability settings in cPanel
  • Folder icon closed Folder open iconDiscontinuation of Barracuda Spam Protection
  • Folder icon closed Folder open iconHow to manage MySQL databases and users in cPanel
  • Folder icon closed Folder open iconHow to manage PostgreSQL databases and users in cPanel
  • Folder icon closed Folder open iconHow to access phpMyAdmin and phpPgAdmin in cPanel
  • Folder icon closed Folder open iconHow to configure remote MySQL access in cPanel
  • Folder icon closed Folder open iconHow to use phpMyAdmin to copy a MySQL database
  • Folder icon closed Folder open iconHow to change the MySQL collation settings in phpMyAdmin
  • Folder icon closed Folder open iconHow to optimize and repair MySQL databases using phpMyAdmin
  • Folder icon closed Folder open iconMySQL passwords do not work after upgrade
  • Folder icon closed Folder open iconHow to delete MySQL database tables using phpMyAdmin
  • Folder icon closed Folder open iconHow to use the cPanel Domains tool
  • Folder icon closed Folder open iconHow to configure redirects in cPanel
  • Folder icon closed Folder open iconAutodiscovery and autoconfiguration DNS records
  • Folder icon closed Folder open iconHow to use the DNS Zone Editor in cPanel
  • Folder icon closed Folder open iconHow to use the cPanel Site Publisher to easily build a website
  • Folder icon closed Folder open iconHow to configure subdomains in cPanel
  • Folder icon closed Folder open iconHow to use log programs in cPanel
  • Folder icon closed Folder open iconHow to view the error log in cPanel
  • Folder icon closed Folder open iconHow to configure and download raw access logs in cPanel
  • Folder icon closed Folder open iconHow to view information about visitors, bandwidth, and resource usage in cPanel
  • Folder icon closed Folder open iconHow to exclude an IP address from AWStats statistics
  • Folder icon closed Folder open iconResource limit information
  • Folder icon closed Folder open iconHow to secure a cPanel-enabled account with a Let's Encrypt SSL certificate
  • Folder icon closed Folder open iconHow to install a third-party SSL certificate with cPanel
  • Folder icon closed Folder open iconHow to install a self-signed SSL certificate in cPanel
  • Folder icon closed Folder open iconHow to configure SSH keys using cPanel
  • Folder icon closed Folder open iconHow to use the IP Blocker in cPanel
  • Folder icon closed Folder open iconHow to configure directory privacy in cPanel
  • Folder icon closed Folder open iconHow to configure leech protection in cPanel
  • Folder icon closed Folder open iconHow to configure hotlink protection in cPanel
  • Folder icon closed Folder open iconHow to manage GnuPG keys in cPanel
  • Folder icon closed Folder open iconHow to secure a cPanel-enabled account with a cPanel SSL certificate
  • Folder icon closed Folder open iconHow to set up AutoSSL on your domain
  • Folder icon closed Folder open iconHow to set up two-factor authentication for cPanel
  • Folder icon closed Folder open iconHow to use Imunify360
  • Folder icon closed Folder open iconHow to manage the ModSecurity module in cPanel
  • Folder icon closed Folder open iconHow to set up cron jobs in cPanel
  • Folder icon closed Folder open iconHow to configure custom Apache handlers in cPanel
  • Folder icon closed Folder open iconHow to create custom error pages in cPanel
  • Folder icon closed Folder open iconHow to configure custom MIME types in cPanel
  • Folder icon closed Folder open iconHow to configure directory indexes in cPanel
  • Folder icon closed Folder open iconHow to install PHP PEAR packages using cPanel
  • Folder icon closed Folder open iconHow to install Perl modules using cPanel
  • Folder icon closed Folder open iconHow to change PHP versions and settings using PHP Selector
  • Folder icon closed Folder open iconHow to use the Python Selector in cPanel
  • Folder icon closed Folder open iconHow to change PHP versions and settings using MultiPHP
  • Folder icon closed Folder open iconHow to use the cPanel Optimize Website feature
  • Folder icon closed Folder open iconHow to create a Node.js application with cPanel using the Node.js Selector
  • Folder icon closed Folder open iconHow to migrate an existing Node.js application to Node.js Selector
  • Folder icon closed Folder open iconHow to use the Application Manager to deploy applications with Passenger
  • Folder icon closed Folder open iconHow to install WordPress using the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to manage WordPress using the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to manage plugins using the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to manage themes using the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to manage multiple sites using the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to stage WordPress with the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to manage WordPress from the command line with the cPanel WordPress Toolkit
  • Folder icon closed Folder open iconHow to configure Web Disk accounts
  • Folder icon closed Folder open iconHow to access Web Disks on Linux and BSD operating systems
  • Folder icon closed Folder open iconHow to access Web Disks on Microsoft operating systems
  • Folder icon closed Folder open iconHow to access Web Disks on Apple operating systems
  • Folder icon closed Folder open iconGetting started with cPanel
    • dfdf
  • Folder icon closed Folder open iconUsing cPanel File Features
    • Using the cPanel File Manager
    • How to restore files, email, and databases using JetBackup
  • Folder icon closed Folder open iconUsing cPanel Mail Features
    • How to forward incoming e-mail messages to a script file
  • Folder icon closed Folder open iconUsing Database Features in cPanel
    • Remote access for MySQL TCP/IP connections on cPanel
  • Folder icon closed Folder open iconUsing the Domain Features in cPanel
  • Folder icon closed Folder open iconUsing the Logging Features in cPanel
  • Folder icon closed Folder open iconSecurity Features in cPanel
    • How to use Imunify Email
  • Folder icon closed Folder open iconAdvanced Features in cPanel
    • How to use Virus Scanner in cPanel
  • Folder icon closed Folder open iconcPanel Software
    • Node.js application error message: "Cannot GET" URL
    • How to migrate an existing application from Node.js Selector to a manual installation
    • How to migrate a Next.js application to the Node.js Selector in cPanel
  • Folder icon closed Folder open iconWordPress Toolkit
    • WordPress Toolkit for resellers
  • Folder icon closed Folder open iconGranting limited cPanel account access to a developer
  • Folder icon closed Folder open iconUsing the Manage Team feature in cPanel

How to manage WordPress from the command line with the cPanel WordPress Toolkit

Estimated reading: 8 minutes 200 views

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.

The wp-toolkit program is part of the cPanel WordPress Toolkit. However, it is currently only available for accounts with root access.

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.

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.

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:

Copywp-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—listcommand, type the following command:

Copywp-toolkit --help -command list

You must run wp-toolkit as the root user.

Listing WordPress installations

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

Copywp-toolkit --list

A listing appears that resembles the following output:

  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

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.

Displaying WordPress installation information

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

Copywp-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:

Copywp-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:

Copywp-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:

Copywp-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:

  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:

Copywp-toolkit --sets -operation add-plugin -set-id 7 -plugin-slug hello-dolly

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

Copywp-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:

Copywp-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:

Copywp-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.

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.

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:

Copywp-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:

Copywp-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:

Copywp-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:

Copywp-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):

Copywp-toolkit --backup -operation restore -instance-id X -filename filename

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

Copywp-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:

Copywp-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.

If there is only one administrator for the specified site, you can omit the -admin-login option.

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:

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

Discover more – How to request Google to review hacked sites and remove Deceptive Site Ahead’ warning

Still stuck? How can we help?

How can we help?

Was this page helpful? Yes No

Share this Doc

How to manage WordPress from the command line with the cPanel WordPress Toolkit

Or copy link

Clipboard Icon
CONTENTS
Leaf Illustration

© 2023 All Rights Reserved by Hostvento