-1

I need to find the total number of email accounts in a cPanel Linux server.

This must include only the active accounts. i.e. only those accounts whose MX is pointing to this server.

1

3 Answers 3

2

You can do it using following one liner.

for i in `cat /etc/localdomains`; do grep -E ^$i: /etc/userdomains ; done | sed 's/://g' | awk '{ system("cat /home/"$2"/etc/"$1"/passwd") }' 2>/dev/null | wc -l
0
0

I have tried this script which checks the users in '/etc/userdomains' and displays the count of total mail accounts in the server.

sed "s|:||g" /etc/userdomains | awk '!/^\* nobody/{print $1, $2 | "sort | uniq" }' | awk '{print "cat /home/"$2"/etc/"$1"/passwd"}' | sh 2>/dev/null | wc -l

but I am looking for a script which could search the /etc/localdomains.

Regards, Ajo

0

You can try this too:

find /home*/*/etc -name passwd -exec cat {} \; | wc -l

Not the answer you're looking for? Browse other questions tagged .