cPanel and WHM commands cheat sheet
Version and updates
-
whmapi1 versionShows the cPanel and WHM version installed on the server. Run whmapi1 as root. By default, the output is in YAML format, and with --output=jsonpretty it's shown as formatted JSON, in every whmapi1 and uapi command.
-
whmapi1 get_update_availabilityChecks whether the server runs the latest version of the release tier selected on it.
-
/usr/local/cpanel/scripts/upcpUpdates cPanel and WHM according to the server's update settings. The update takes a few minutes, so it's best to run it during a quiet period.
-
/usr/local/cpanel/scripts/upcp --bgRuns the update in the background and writes the output to a file in /var/cpanel/updatelogs. Useful when your SSH connection might drop midway.
-
/usr/local/cpanel/scripts/upcp --forceReinstalls all files, even when the system is up to date. Caution: this option overrides the update settings and moves the server to the latest version. Don't combine it with --sync.
-
/usr/local/cpanel/scripts/check_cpanel_pkgs --fixScans the cPanel software packages, lists broken or missing packages, and fixes them. The check takes a few minutes, and when there are no problems, it finishes without any output.
Services and server settings
-
/usr/local/cpanel/scripts/restartsrv_httpdRestarts the Apache web server. The same pattern works for other services: restartsrv_exim for the Exim mail server, restartsrv_dovecot for IMAP and POP3, restartsrv_mysql for the database, restartsrv_pdns or restartsrv_named for DNS (depending on the installed DNS server), and restartsrv_cpsrvd for the cPanel and WHM interface itself.
-
/usr/local/cpanel/scripts/restartsrv_exim --checkChecks whether the service is running, without restarting it. Other options include --start, --stop, --reload, and --graceful. Some options aren't available for every service.
-
whmapi1 servicestatus service=eximShows whether the service is enabled, installed, and monitored. Without the service parameter, it shows the status of every service on the server.
-
/usr/local/cpanel/scripts/find_outdated_servicesFinds services that need a restart after system libraries are updated, and asks before each restart. With --never-restart, it only lists them.
-
/usr/local/cpanel/scripts/rebuildhttpdconfRebuilds the main Apache configuration file. The script doesn't restart Apache, so run restartsrv_httpd afterward. With --preview, the output is written to httpd-preview.conf so you can review it before the change.
-
/usr/local/cpanel/bin/set_hostname server.example.comChanges the server's hostname. The name must be a fully qualified domain name (FQDN) that doesn't start with www or a digit.
Account management
-
whmapi1 listaccts want=user,domain,plan,diskused,suspendedLists every account on the server with only the selected fields: username, main domain, package, disk usage, and suspension status.
-
whmapi1 listaccts searchtype=domain searchmethod=exact search=example.comFinds the account a domain belongs to. With searchtype, you can also search by user, owner, ip, or package.
-
whmapi1 createacct username=username domain=example.com plan=default contactemail=admin@example.comCreates a new cPanel account with a domain, a package, and a contact email address. If you don't set a password, the system generates a secure one.
-
whmapi1 changepackage user=username pkg=package1Moves an account to a different package, with the new package's limits.
-
whmapi1 modifyacct user=username contactemail=admin@example.comChanges the details of an existing account, such as the contact address, the main domain (DNS), or the username (newuser). For an account assigned to a package, a change to the package overrides values set manually.
-
whmapi1 passwd user=username password='NewPass-2026!'Changes an account's password. With db_pass_update=1, the account's MySQL password is updated too. The password is saved in the terminal's command history, so it's best to clear it afterward.
-
whmapi1 suspendacct user=username reason=NonpaymentSuspends an account and keeps its data. Always give a reason for the suspension. With disallowun=1, only root can unsuspend the account.
-
whmapi1 unsuspendacct user=usernameUnsuspends an account and brings all its services back online.
-
whmapi1 removeacct username=usernamePermanently deletes an account: files, databases, email, and DNS records. Caution: this can't be undone and runs without asking for confirmation, so create a backup with pkgacct before you delete. With keepdns=1, the DNS records are kept.
Backup and restore
-
/usr/local/cpanel/scripts/pkgacct username /rootPackages a complete account into a single backup file (cpmove) in the specified directory: files, databases, email, DNS, and settings. Without a directory, the file is saved in the home directory with the most free space.
-
/usr/local/cpanel/scripts/pkgacct --skiphomedir username /rootPackages the account without its home directory, for example when you move the files separately with rsync. The --skipmail option skips the mail directory, and the --dbbackup=schema option saves only the table structure of the databases.
-
/usr/local/cpanel/scripts/restorepkg /root/cpmove-username.tar.gzRestores an account from a cpmove file. Useful for moving an account between servers: package it on the old server with pkgacct, copy the file, and restore it on the new server.
-
/usr/local/cpanel/bin/backup --forceRuns the scheduled backup now, according to the backup settings in WHM, even when recent backups already exist. The log is saved in /usr/local/cpanel/logs/cpbackup.
-
whmapi1 backup_config_getShows the server's backup settings: the backup type, the destination directory (/backup by default), the frequency, and the number of copies kept.
-
uapi --user=username Backup fullbackup_to_homedirCreates a full backup of the account in its home directory, in a file named backup-MM.DD.YYYY_HH-mm-ss_username.tar.gz. The backup runs in the background, and its duration depends on the account's size.
DNS
-
whmapi1 listzonesLists every DNS zone on the server, with the zone file name of each domain.
-
whmapi1 parse_dns_zone zone=example.comShows every record in a DNS zone. Record values are shown base64-encoded. The older dumpzone function is deprecated, and parse_dns_zone replaces it.
-
whmapi1 addzonerecord domain=example.com name=www.example.com. class=IN ttl=14400 type=A address=192.0.2.10Adds an A record to the zone. Keep the trailing dot at the end of the full record name.
Email and the Exim queue
-
uapi --user=username Email list_popsLists an account's mailboxes. The uapi command runs as a specific cPanel account, which you specify after --user.
-
uapi --user=username Email add_pop email=info domain=example.com password='Mail-Pass-2026' quota=1024Creates the mailbox info@example.com with a 1024 MB quota. Wrap values that contain special characters, such as the password, in single quotes so the shell doesn't interpret them.
-
uapi --user=username Email delete_pop email=info@example.comDeletes a mailbox. Caution: by default, the mail directory and all the messages in it are deleted too.
-
exim -bpcShows the number of messages waiting in the mail queue. The commands in this section are standard Exim commands, and you run them as root.
-
exim -bp | exiqsummShows a summary of the mail queue by destination domain: the number of messages, their total size, and the age of the oldest message.
-
exiqgrep -f '<sender@example.com>' -iLists the IDs of queued messages sent from a specific address. The angle brackets limit the search to the exact address; without them, longer addresses that contain it match too. The -r option searches by recipient, -z shows only frozen messages, and -o with a number of seconds shows messages older than that.
-
exiqgrep -z -i | xargs exim -MrmDeletes all frozen messages from the queue. Caution: messages deleted from the queue can't be recovered.
-
exiqgrep -f '<sender@example.com>' -i | xargs exim -MrmDeletes all queued messages sent from a specific address, for example after a mailbox was compromised and sent spam. Caution: this can't be undone.
SSL certificates and AutoSSL
-
/usr/local/cpanel/bin/autossl_check --user=usernameRuns an AutoSSL check for one account: issues or renews certificates for the domains that need it.
-
/usr/local/cpanel/bin/autossl_check --allRuns an AutoSSL check for every account on the server. On a server with many accounts, the check takes a long time.
-
whmapi1 get_autossl_problems_for_domain domain=example.comShows the latest domain control validation (DCV) problems that prevented a certificate from being issued, for example a DNS record that doesn't point to the server.
-
uapi --user=username SSL installed_hostsLists an account's websites, their domains, and the details of the certificate installed on each site, including its expiration date.
PHP versions
-
whmapi1 php_get_installed_versionsLists the PHP versions installed on the server, with names like ea-php83 and ea-php84.
-
whmapi1 php_get_vhost_versionsShows the PHP version of each site on the server, and whether PHP-FPM is enabled for it.
-
whmapi1 php_set_vhost_versions version=ea-php84 vhost=example.comChanges the PHP version of one site. The value inherit returns the site to the default version. Check the site right after the switch.
-
uapi --user=username LangPHP php_get_vhost_versionsShows the PHP versions of the sites in a single account only.
-
/usr/local/cpanel/bin/rebuild_phpconf --currentShows the default version and the handler of each PHP version. With options that make changes, such as --default, the settings change right away and Apache restarts, unless you add --dryrun to only test the change.
-
/usr/local/bin/ea-php84 script.phpRuns a script with a specific PHP version from the command line, regardless of the version set for the directory.
Databases
-
uapi --user=username Mysql list_databasesLists an account's databases, with the size and users of each database.
-
uapi --user=username Mysql create_database name=username_shopCreates a database. When database prefixing is enabled on the server, the database name starts with the username and an underscore.
-
uapi --user=username Mysql set_privileges_on_database user=username_shopuser database=username_shop privileges=SELECT,INSERT,UPDATE,DELETEGrants a user privileges on a database. You can specify a comma-separated list of privileges, based on what the site needs.
Security and cPHulk
-
whmapi1 cphulk_statusShows whether cPHulk, the protection against password guessing (brute force), is enabled on the server. The enable_cphulk and disable_cphulk commands turn it on and off.
-
whmapi1 flush_cphulk_login_history_for_ips ip=192.0.2.10Unblocks an IP address that was blocked after failed login attempts, for example when a user mistyped their password several times.
-
/usr/local/cpanel/scripts/cphulkdwhitelist 192.0.2.10Adds an IP address to the cPHulk allowlist so it isn't blocked. Useful for the fixed IP address of your office or of the server administrator.
-
/usr/local/cpanel/scripts/configure_firewall_for_cpanelConfigures the cPanel and WHM ports in the firewalld firewall. Caution: the script deletes your existing iptables rules, so save them first with iptables-save.
Log locations
-
tail -n 100 /usr/local/cpanel/logs/error_logThe cPanel and WHM error log. The same directory also holds access_log for interface access and login_log for login attempts.
-
ls -lt /var/cpanel/updatelogsThe directory of the cPanel update logs. The top file in the list belongs to the latest update.
-
tail -n 100 /var/log/apache2/error_logThe Apache error log. The access logs of each site are in /etc/apache2/logs/domlogs, in a file named after the domain.
-
tail -f /var/log/exim_mainlogThe log of incoming and outgoing mail, followed live. Rejected messages are logged in /var/log/exim_rejectlog.
-
tail -n 100 /var/log/maillogIMAP and POP3 logins and mail delivery to mailboxes. On Ubuntu servers, the file is /var/log/mail.log.
-
tail -n 100 /usr/local/cpanel/logs/cphulkd.logThe cPHulk activity log: blocks and failed login attempts.
No matching commands.
Before you work with cPanel and WHM from the command line
- whmapi1 and uapi: The whmapi1 command works at the server level and manages accounts, services, and settings. The uapi command works inside a single cPanel account, which you specify after --user. The older cPanel API 2 is deprecated, and UAPI replaces it.
- Full paths: The scripts are in the /usr/local/cpanel/scripts and /usr/local/cpanel/bin directories. On a server with CloudLinux, run whmapi1 and uapi with their full paths in /usr/local/cpanel/bin as well.
- Back up before changes: Before you delete, restore, or change an account, create a backup with pkgacct so you can return to the previous state.
- Ports: The cPanel interface is available on port 2083, WHM on port 2087, and Webmail on port 2096, all over a secure connection.
The usernames, domains, IP addresses, and passwords on this page are examples, so replace them with your real values. For an explanation of the records you add to a DNS zone, see DNS record types, and for commands that work with the database itself, see MySQL commands.
On a Linux VPS, you can choose cPanel and WHM as the control panel, licensed by the number of accounts and installed by our team. You connect over SSH with full root access and run every command on this page directly on the server.
cPanel and WHM commands FAQ
What's the difference between cPanel and WHM?
WHM is the management interface for the whole server, where the server administrator creates accounts and sets up packages, services, backups, and security. cPanel is the interface for a single account, where the site owner manages their files, mailboxes, databases, and domains. On the command line, the difference is similar: whmapi1 works at the server level, and uapi works inside a specific account.
How do I move a cPanel account to another server?
On the old server, package the account with /usr/local/cpanel/scripts/pkgacct, which creates a single cpmove file with the files, databases, email, and settings. Copy the file to the new server, for example with scp or rsync, and restore it with /usr/local/cpanel/scripts/restorepkg. After you check everything on the new server, point the domain's DNS records to the new address.
How do I check which cPanel version is installed and update it?
The whmapi1 version command shows the installed version, and whmapi1 get_update_availability checks whether a newer version is available in the server's release tier. The tier is set in /etc/cpupdate.conf or on the Update Preferences screen in WHM, with the options LTS, STABLE, RELEASE, CURRENT, and EDGE. To update manually, run /usr/local/cpanel/scripts/upcp.
How do I unblock an IP address that was blocked when logging in to cPanel?
When a user mistypes their password several times, cPHulk may block their IP address. The server administrator unblocks the address with whmapi1 flush_cphulk_login_history_for_ips and the address, or on the cPHulk Brute Force Protection screen in WHM. To keep a fixed address, such as your office's, from being blocked again, add it to the allowlist with /usr/local/cpanel/scripts/cphulkdwhitelist.
How do I see which messages are stuck in the mail queue?
The exim -bpc command shows how many messages are waiting in the queue, and exim -bp with exiqsumm shows a summary by destination domain. To find out why a message wasn't sent, search for its ID in /var/log/exim_mainlog. A queue that suddenly grows is usually a sign of a compromised mailbox sending spam, so change the mailbox password and clear its messages from the queue.