cPanel provides a set of command-line tools and scripts that help you manage hosting accounts, services, and system tasks.
Using these commands can save time when you need to work on the server directly or automate routine operations.
This guide covers the most useful cPanel and WHM commands you will need.

Prerequisites

Before you begin:

  • Root or sudo access on the server
  • Basic command-line skills
  • cPanel & WHM installed

1. Account Management Commands

Use these scripts to create, suspend, or list accounts:

  • Create a new account
    /usr/local/cpanel/scripts/createacct userdomain.com username password
  • Suspend an account
    /usr/local/cpanel/scripts/suspendacct username
  • Unsuspend an account
    /usr/local/cpanel/scripts/unsuspendacct username
  • List all accounts
    whmapi1 listaccts

2. Service Management Commands

Restart or check status of key services:

  • Restart Apache
    /usr/local/cpanel/scripts/restartsrv_httpd
  • Restart cPanel service
    /usr/local/cpanel/scripts/restartsrv_cpsrvd
  • Restart Exim (mail)
    /usr/local/cpanel/scripts/restartsrv_exim
  • Check service status with systemctl
    systemctl status cpsrvd

3. System Update and Maintenance

Keep cPanel up to date and check system health:

  • Update cPanel to the latest version
    /usr/local/cpanel/scripts/upcp
  • Check for security updates
    yum check-update
  • Apply all available updates
    yum update -y

4. Email Management Commands

Manage email accounts and queues:

  • List email accounts for a user
    uapi --user=username Email list_pops
  • Remove an email account
    uapi --user=username Email delete_pop email=user@domain.com
  • Check Exim mail queue
    exim -bpc
  • Flush the mail queue
    exim -qff

5. Database Management Commands

Work with MySQL and MariaDB:

  • List all databases
    mysql -e "SHOW DATABASES;"
  • Create a database
    uapi --user=username Mysql create_database name=dbname
  • Backup all databases
    mysqldump --all-databases > /root/all_databases.sql

6. DNS and Domain Commands

Handle DNS zones and domain settings:

  • List DNS zones
    whmapi1 listzones
  • Add a DNS record
    whmapi1 addzonerecord zone=domain.com name=sub.domain.com type=A address=1.2.3.4
  • Update user domains
    /usr/local/cpanel/scripts/updateuserdomains

7. Backup and Restore Commands

Control cPanel backups:

  • Run a full backup for an account
    /usr/local/cpanel/scripts/pkgacct username
  • Restore a full backup
    /usr/local/cpanel/scripts/restorepkg username

Conclusion

Mastering these common commands will help you manage cPanel servers more efficiently.
Always test scripts in a safe environment before using in production.
For dedicated server hosting that offers full root access and high performance, check out our plans starting at 20 USD per month 

Ця відповідь Вам допомогла? 321 Користувачі, які знайшли це корисним (321 Голосів)