How to detect user's existence over UNIX - Unix

This is a discussion on How to detect user's existence over UNIX - Unix ; Is there any generic way to detect user's existence over RHEL and Solaris? I want to write a shell script to do so. Thanks....

+ Reply to Thread
Results 1 to 9 of 9

Thread: How to detect user's existence over UNIX

  1. How to detect user's existence over UNIX

    Is there any generic way to detect user's existence over RHEL and
    Solaris? I want to write a shell script to do so. Thanks.


  2. Re: How to detect user's existence over UNIX

    Neo wrote:
    > Is there any generic way to detect user's existence over RHEL and
    > Solaris? I want to write a shell script to do so. Thanks.
    >

    If you don't specify the meaning of "user's existence", you will most
    probably get no significant help.

    Herbert

  3. Re: How to detect user's existence over UNIX

    Neo writes:
    > Is there any generic way to detect user's existence over RHEL and
    > Solaris? I want to write a shell script to do so. Thanks.


    Leaving issue of non-atomicness aside, you could use the id command
    for that. 'id ' while return a non-zero exit status the user
    does not exist. This is not the only reason which may cause it to
    fail, but presumably, the most 'common' one, and it should be able to
    deal with things like NIS maps.

  4. Re: How to detect user's existence over UNIX

    Neo writes:
    > Is there any generic way to detect user's existence over RHEL and
    > Solaris? I want to write a shell script to do so. Thanks.


    Leaving issue of non-atomicness aside, you could use the id command
    for that. 'id ' will return a non-zero exit status the user
    does not exist. This is not the only reason which may cause it to
    fail, but presumably, the most 'common' one, and it should be able to
    deal with things like NIS maps.

  5. Re: How to detect user's existence over UNIX

    Rainer Weikusat wrote:
    > Neo writes:
    >> Is there any generic way to detect user's existence over RHEL and
    >> Solaris? I want to write a shell script to do so. Thanks.

    >
    > Leaving issue of non-atomicness aside, you could use the id command
    > for that. 'id ' while return a non-zero exit status the user
    > does not exist.


    Alternate method #1:
    groups

    Alternate method #2:
    getent passwd

    - Logan

  6. Re: How to detect user's existence over UNIX

    On Oct 19, 7:01 am, Logan Shaw wrote:
    > Rainer Weikusat wrote:
    > > Neo writes:
    > >> Is there any generic way to detect user's existence over RHEL and
    > >> Solaris? I want to write a shell script to do so. Thanks.

    >
    > > Leaving issue of non-atomicness aside, you could use the id command
    > > for that. 'id ' while return a non-zero exit status the user
    > > does not exist.

    >
    > Alternate method #1:
    > groups
    >
    > Alternate method #2:
    > getent passwd
    >
    > - Logan


    Thanks for all for help !


  7. Re: How to detect user's existence over UNIX

    On Wed, 17 Oct 2007 22:19:52 -0700, Neo wrote:

    > Is there any generic way to detect user's existence over RHEL and
    > Solaris? I want to write a shell script to do so. Thanks.


    Do RHEL and Solaris have an /etc/passwd file?

  8. Re: How to detect user's existence over UNIX

    jellybean stonerfish wrote:
    > On Wed, 17 Oct 2007 22:19:52 -0700, Neo wrote:
    >
    >> Is there any generic way to detect user's existence over RHEL and
    >> Solaris? I want to write a shell script to do so. Thanks.

    >
    > Do RHEL and Solaris have an /etc/passwd file?


    Sure, probably, but what makes you think that's a reliable way to
    determine a user's existence?

    - Logan

  9. Re: How to detect user's existence over UNIX

    jellybean stonerfish writes:
    > On Wed, 17 Oct 2007 22:19:52 -0700, Neo wrote:
    >> Is there any generic way to detect user's existence over RHEL and
    >> Solaris? I want to write a shell script to do so. Thanks.

    >
    > Do RHEL and Solaris have an /etc/passwd file?


    They both support a multiplicty of local and remote 'directory
    databases' (eg files, NIS, NIS+, LDAP etc) which could be use to
    determine this information. Since standardized tools to access it
    exist, it is sensible to use them in a shell script instead of
    accessing a or some particular database(s) directly.


+ Reply to Thread