How to get a list of total cPanel users under a specific re-seller via command line – WHM/cPanel server

Do you wish to list all cPanel accounts under a specific reseller?

If so, it’s very simple to list all cPanel users’ name via command line interface (CLI). There is a file ‘/etc/trueuserowners‘ in your WHM server which has all cPanel username and it’s owner’s name details. We can simply grep out our requirement from this file 🙂

File which has user:owner details is:

/etc/trueuserowners

List all users under a reseller account

Please do follow the steps pasted below to list out all cPanel accounts a particular reseller account:

Step 1 : SSH to server as root user.

Step 2 : You can use the grep and cut command to list all users’ name from /etc/trueuserowners file.

Syntax

# grep $Re-seller's-name /etc/trueuserowners | cut -d : -f 1

$Re-seller’s : replace it with the re-seller acount name

Example

# grep crybit /etc/trueuserowners | cut -d : -f 1
tieuwn
sinwe8
crybit
dewan

That’s it 🙂

## Update  ##

Is there any command to sort-out Resellers who created more cPanel accounts?

You can use the following command to list/sort reseller accounts with high cPanel accounts. Please do follow the steps pasted below:

Step 1 : SSH to server as root user.

Step 2 : Copy all reseller accounts name to a file.

grep -o '^[a-z][a-z0-9]\{0,7\}' /var/cpanel/resellers > resellers.txt

Step 3 : Execute the “for” loop to sort out reseller accounts with its cPanel count.

for i in `cat reseller.txt`; do grep $i /etc/trueuserowners|cut -d : -f 2;done |sort|uniq -c|sort -nr|less

That’s it!!

Related:
check the version of your WHM/cPanel from command line
Important cPanel service’s configuration file, path, service name, port – Command line view
How to terminate/delete a cPanel account through SSH

Something more about cPanel  , See the category CPANEL

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

9 thoughts on “How to get a list of total cPanel users under a specific re-seller via command line – WHM/cPanel server

  1. Hello,

    You can use below command to get top 10 reseller who create more cPanel users.

    for i in `cat resellers.txt`; do grep $i /etc/trueuserowners|cut -d : -f 2;done |sort|uniq -c|sort -rn | head

  2. Hello,

    Is there a command to list accounts by packages ? I mean this can help to see which accounts have same package.

Leave a Reply

Your email address will not be published. Required fields are marked *