How to remove / terminate an entire reseller account via the command line in cPanel?

269ac00f765508cb74b25d006dbf5bb2

Written by Dennis Nind

Last published at: April 9th, 2019

Occasionally, it may be required that you will need to remove a full reseller from a cPanel server. This can be done via the WHM interfaces, however can be more convenient through the command line.

To do this, we generally use the following script...

for user in $(grep reseller_user_name /etc/trueuserowners | awk -F":" '{print $1}'); do /scripts/removeacct $user --force --keepdns; done;

Of course, replacing the 'reseller_user_name' value with the actual resellers username. 

Additional Flags

In the example above, we have added...

--force - This will avoid the 'prompt', which required you to confirm each account removal and will instead just force the termination of each account

--keepdns - We add this flag because we are using a 'DNS Cluster'. As such, removal of the account DNS will also feed back to the DNS clusters themselves. This is fine, if the client / reseller has 'moved' elsewhere and the account is no longer required, however it may be the case that the reseller has simply been moved to a new machine. In this case, the DNS will need to remain intact.