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 Ashok

Operations Engineer at Endurance International Group. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com
We like to travel. Our travelogues are published at Trip Mentor

8 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 *