1753711 Members
4604 Online
108799 Solutions
New Discussion юеВ

Re: check username

 
SOLVED
Go to solution
Mauro Gatti
Valued Contributor

check username

Hi All, I'd like to know if exists a way to check if a given userid esists on system or not.
I'd like to have an exit status like 0 = exist 1 = doesn't exist...
Do You know what I can do?

Thank you
Ubi maior, minor cessat!
5 REPLIES 5
Pete Randall
Outstanding Contributor
Solution

Re: check username

grep username /etc/passwd

Pete
Jose Mosquera
Honored Contributor

Re: check username

Hi,

This way is full specific user's name retrieval:

#grep ^username: /etc/passwd

Rgds.
T G Manikandan
Honored Contributor

Re: check username

#logins|awk -F " " '{print $1}'|grep

Robin Wakefield
Honored Contributor

Re: check username

Hi,

If you want to check NIS too, then maybe use perl:

var=`perl -e '{print ! (defined getpwnam shift)|| 0}' username`

this will give you the return codes as in your question.

rgds, Robin
Norman_21
Honored Contributor

Re: check username

Hi,

Another way,

#more /etc/passwd
press and type the user name you are looking for.
e.g) \username and press Enter key get the result.

Thanks.
"Attitudes are contagious, is yours worth catching"/ My first point was given by SEP on January 31, 2003