Want to list all cPanel accounts under a reseller? Use this simple shell script!

1️⃣ Create Script

vi /home/reseller.sh

Add:

#!/bin/bash

usage() { echo “Usage: $0 domain.com or username”; exit 1; }
test $1 || usage
USERN=$(grep $1 “/etc/userdomains” | awk ‘{print $NF}’ | awk ‘NR==1’)
[[ -z $USERN ]] && { echo “$1 is not a reseller”; exit 1; }
OWNER=$(cut -d: -f1 /var/cpanel/resellers | grep -o $USERN)
[[ $? -eq 0 ]] && { echo “Accounts under $OWNER:”; grep USER= /var/cpanel/users/* -l | awk -F”=” ‘{ print $2 }’; } || { echo “$1 is not a reseller”; exit 1; }

2️⃣ Set Permissions & Run

chmod 755 /home/reseller.sh
./reseller.sh resellerusername

✅ Output: Lists all associated accounts.

By admin