get owner username from command line using domain name

craigedmonds

Well-Known Member
Oct 29, 2007
115
1
68
Europe
cPanel Access Level
Root Administrator
Twitter
Is there a way for me to type a domain/subdomain/addon domain/parked domain in ssh and it tells me the username of the account it belongs to?

For example, if I typed this..

Code:
# /root/querydomain.sh some_add_on_domain-com
It would return something like this...

Code:
# owner username for some_add_on_domain-com is: joebloggs
Then I would be able to make another query which allows me to make changes to /home/joebloogs

The issue I have is that I have a really nice bash script for something else, but I have to know the username first before I can execute it and the only ay to do it is to open WHM » Home »Account Information »List Subdomains ,t hen do CTRL + F to find the domain and see who owns it.

So would make my life easier if I could just type the domain name in the script and then execute what I need.
 

craigedmonds

Well-Known Member
Oct 29, 2007
115
1
68
Europe
cPanel Access Level
Root Administrator
Twitter
You could just do a locate domain.com which would give you a few locations one of which would be /home/username/domain.com
Code:
locate domain.com
cool. that gives ALOT of paths. ALL i need to do now is parse them and I will be able to get the owner username.

Thanks!
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Hello :)

Yes, the following script should work for you:

Code:
/scripts/whoowns $domain
You could also search for the domain name in the /etc/userdomains file. EX:

Code:
grep $domain /etc/userdomains
Thank you.