Script or Command to get all username

I am not too good with unix. I need a script that will give me a result of all username, Display name, and password in a text file.

Thanks
 
It just give the username and not the display name and the password. I need something that could give me username together with the display name and/or the password
 
Uh, I didn't read the complete message.
That will give you only the usernames.
You can get the complete name using -f 5.
And about the password...
 
You can't get the password easily. The passwords are stored in an encrypted form in the root-readable-only file /etc/master.passwd, encrypted with crypt(3).
 
awk comes in handy for parsing text files that have a unique field separator. For /etc/passwd and /etc/master.passwd, the colon :)) is the field separator. So all you need to do is figure out which field(s) to print, and tell awk to print them:
Code:
# cat /etc/master.passwd | awk -F":" '{ printf "%s %s %s\n",$1,$5,$2 }'
That will print field 1 (username), field 5 (full name), and field 2 (password), as they are stored in /etc/master.passwd.

To make it look nicer, you can add labels:
Code:
# cat /etc/master.passwd | awk -F":" '{ printf "username: %s  name: %s  password: %s\n",$1,$5,$2 }'
 
Back
Top