| Author |
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.
| |
| Herbert Pophal 2007-10-18, 4:21 am |
| 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
| |
| Rainer Weikusat 2007-10-18, 4:21 am |
| Neo <vikram.sutar@gmail.com> 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 <username>' 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.
| |
| Rainer Weikusat 2007-10-18, 4:21 am |
| Neo <vikram.sutar@gmail.com> 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 <username>' 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.
| |
| Logan Shaw 2007-10-18, 10:10 pm |
| Rainer Weikusat wrote:
> Neo <vikram.sutar@gmail.com> writes:
>
> Leaving issue of non-atomicness aside, you could use the id command
> for that. 'id <username>' while return a non-zero exit status the user
> does not exist.
Alternate method #1:
groups <username>
Alternate method #2:
getent passwd <username>
- Logan
| |
|
| On Oct 19, 7:01 am, Logan Shaw <lshaw-use...@austin.rr.com> wrote:
> Rainer Weikusat wrote:
>
>
> Alternate method #1:
> groups <username>
>
> Alternate method #2:
> getent passwd <username>
>
> - Logan
Thanks for all for help !
| |
| jellybean stonerfish 2007-10-24, 4:32 am |
| 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?
| |
| Logan Shaw 2007-10-24, 4:32 am |
| jellybean stonerfish wrote:
> On Wed, 17 Oct 2007 22:19:52 -0700, Neo wrote:
>
>
> 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
| |
| Rainer Weikusat 2007-10-24, 4:32 am |
| jellybean stonerfish <stonerfish@geocities.com> writes:
> On Wed, 17 Oct 2007 22:19:52 -0700, Neo wrote:
>
> 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.
|
|
|
|