All posts

How to Force Remove a cPanel Account in WHM via Terminal

Feb 28, 2025 2 min read Cyberison Team Updated Dec 4, 2026
In this guide
  1. Step 1: Backup the Account (Recommended)
  2. Step 2: Try Removing the Account Using WHM Script
  3. Step 3: Manually Remove the cPanel Account
  4. 3.1 Delete cPanel Account Data
  5. 3.2 Remove the User and Home Directory
  6. 3.3 Clean Up cPanel Records
  7. 3.4 Refresh WHM Services
  8. Step 4: Verify Account Deletion
  9. Step 5: Final Cleanup
  10. Will This Affect Other cPanel Accounts?

If you cannot delete a cPanel account through WHM, follow these steps to manually remove it.

Before deleting the account, create a backup to avoid accidental data loss:

tar -czvf /root/cpusername-backup.tar.gz /home/cpusername

Hint: Replace cpusername with the actual cPanel username.

Step 2: Try Removing the Account Using WHM Script

Run the cPanel account removal script:

/scripts/removeacct cpusername

Hint: Replace cpusername with the actual cPanel username.

If this command successfully removes the account, you’re done! ???? If it fails, proceed with the manual removal.

Step 3: Manually Remove the cPanel Account

3.1 Delete cPanel Account Data

Remove the cPanel user configuration files:

rm -rf /var/cpanel/users/cpusername

Hint: Replace cpusername with the actual cPanel username.

3.2 Remove the User and Home Directory

Delete the system user and its home directory:

userdel -r cpusername
rm -rf /home/cpusername

Hint: Replace cpusername with the actual cPanel username.

3.3 Clean Up cPanel Records

Remove the account from WHM records:

sed -i "/: cpusername$/d" /etc/userdomains /etc/trueuserdomains
sed -i "/^cpusername:/d" /etc/trueuserowners

Hint: Replace cpusername with the actual cPanel username.

Update the user domain records:

/scripts/updateuserdomains

3.4 Refresh WHM Services

Rebuild Apache configuration:

/scripts/rebuildhttpdconf

Restart essential services:

service httpd restart
service cpanel restart

Step 4: Verify Account Deletion

Check if the account is still present:

grep cpusername /etc/passwd
ls -l /var/cpanel/users | grep cpusername

Hint: Replace cpusername with the actual cPanel username.

If both commands return no output, the account has been successfully removed.

Step 5: Final Cleanup

If the account still appears in WHM, refresh the WHM cache:

/scripts/fixeverything

Finally, log in to WHM and ensure that the account is no longer listed under List Accounts.

Will This Affect Other cPanel Accounts?

No, these steps will not impact other cPanel accounts because:

  • They only target cpusername.
  • They do not modify system-wide settings or configurations.

Following this guide ensures a complete and safe removal of the cPanel account.

Share this guide