cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,203
363
Hello :)

You can find addon domain information in several locations. This includes:

Code:
/var/cpanel/users/$username
/var/cpanel/userdata/$username/
/etc/userdatadomains
If you are seeking to extract which domain names are addon domain names, then the "/etc/userdatadomains" file may be the best option. EX:

Code:
# grep addon /etc/userdatadomains
Thank you.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
If you would like to strip this information down to the user's domains only without the output from the entire line (not to mention, if a subdomain has addon in it, then you'll get that if you don't refine the grep):

Code:
#grep "=addon" /etc/userdatadomains | awk {'print $1,$2'} | cut -d= -f1 | uniq -c | sort -n
      1 addon.com: myuser
      1 addon2.com: myuser
This represents two addon domains (addon.com and addon2.com owned by the user myuser).

Without the = portion, I was getting the following:

Code:
#grep "addon" /etc/userdatadomains | awk {'print $1,$2'} | cut -d= -f1 | uniq -c | sort -n
      1 addon.com: myuser
      1 addon.domain.com: myuser
      1 addon2.com: myuser
That's because addon.domain.com has addon in the name even though it's a subdomain. Unless you also want subdomains, you'd want to use "=addon" in the grep.

Next, if you simply want to count the addon domains for a user without listing the domain names individually:

Code:
#grep "=addon" /etc/userdatadomains | awk {'print $2'} | cut -d= -f1 | uniq -c | sort -n
      2 myuser
This outputs the count of the two addon domains that myuser owns.