The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Finding domain's username on server (easy!)

Discussion in 'General Discussion' started by alwaysweb, Apr 8, 2003.

  1. alwaysweb

    alwaysweb Well-Known Member

    Joined:
    Mar 8, 2002
    Messages:
    97
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Dallas, TX
    cPanel Access Level:
    Root Administrator
    I'm sure you've all scratched your head a time or two when you need to find the username for 'xyz.com' on the server, right?

    This easy shell script script solution. Login to root via SSH and do this:

    pico /usr/local/bin/finddom

    paste in this text (between the lines, NOT including the lines):

    -----------------------------------------------------------------
    #!/bin/sh

    OUTPUT=`grep -r "$1" /etc/trueuserdomains`

    if [ "$OUTPUT" != "" ]; then

    OUTPUT2=`echo $OUTPUT | cut -d":" -f2`;
    echo "";
    echo "$1 is username: $OUTPUT2";
    echo "";

    else
    echo " -- NO Match --";
    fi

    exit 0;
    -----------------------------------------------------------------

    Now, set permissions on it so you can run it:

    chmod 700 /usr/local/bin/finddom


    Now, next time you need to find xyz.com on the server, do this from SSH:

    finddom xyz.com

    or

    finddom xyz

    (or any unique part of the domain name) and it will quickly tell you the account username.

    Cpanel is welcome to include this is any Cpanel build they want, possibly in the /scripts folder...

    I use this at least 10 times a day, and hope it will help you too! Enjoy! :D
     
  2. jmc67

    jmc67 Well-Known Member

    Joined:
    Mar 10, 2002
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    16
    Nice tip! Have more? :D
     
  3. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Nice little script and thanks for sharing.

    A small bug I found though, if an account has been setup as a Sub-domain name using the Domain name of an already setup account, they will both show, but only one account ID.

    As I never use the first 8 charactors of a Domain name for the account ID, I have found myself needing something for same the reason, but on the flip side. Starting with an account ID and trying to find what their Domain is, because of various checking I sometimes need to do. I 'tail' error logs a lot. :D

    Having to constantly refer to WHM for a matchup, I changed a few variables and came up with:

    -----------------------------------------------------------------

    #!/bin/sh

    OUTPUT=`grep -r "$1" /etc/trueuserdomains`

    if [ "$OUTPUT" != "" ]; then

    OUTPUT2=`echo $OUTPUT | cut -d":" -f1`;
    echo "";
    echo "$1 use's the Domain name of: $OUTPUT2";
    echo "";

    else
    echo " -- NO Match --";
    fi

    exit 0;

    -----------------------------------------------------------------

    So I call my code 'finddom' and the code by alwaysweb, 'findid' for convienence. Wouldn't take much (I think, shall have to check it out later) to write some similar code to determine who owns the account. (i.e. which Reseller)
     
  4. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,426
    Likes Received:
    2
    Trophy Points:
    38
    cPanel Access Level:
    DataCenter Provider
    err

    /scripts/whoowns domainhere

    :)
     
  5. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Too complicated. :)

    ./scripts/whoowns domainhere

    does not work, one must cd to scripts then run ./whoowns. One line commands like above are easier on the brain.

    I guess one could do a sym link (for the first code posted) to that script, but how would one reverse it? Using something for finding out the owner of an account -- one line code -- would be handy though.
     
  6. Elena

    Elena Well-Known Member

    Joined:
    Aug 10, 2001
    Messages:
    109
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    California
    Why not go to WHM>Account Functions>List Accounts and then on that page just go to the bottom... enter in the domain name and hit Find button.. and poof! you've got the accounts main info right there. Seems easier to me that way :D

    The list accounts page also has the option to search by owner/reseller, domain, user, package and ip address...
     
    #6 Elena, Apr 9, 2003
    Last edited: Apr 9, 2003
  7. casey

    casey Well-Known Member

    Joined:
    Jan 17, 2003
    Messages:
    2,303
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    If there is trouble, it will find me
    No you don't. Just type /scripts/whoowns domainhere at the prompt, and there it is.
     
  8. Admin356

    Admin356 Active Member

    Joined:
    Feb 19, 2003
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    1
    Edit ~/.bashrc

    Add

    alias whoowns='/scripts/whoowns'

    The next login you can simply type: whoowns domain.com :)
     
  9. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    All over Europe
    very interesting script (/scripts/whoowns) but for addon domains it will display the user that created the addon and not the username that was assigned to this specific addon domain.

    Any function that will show the specific username for an addon domain? I can find it in httpd.conf but I need something similar to /scripts/whoowns

    kosmo
     
Loading...

Share This Page