etc/passwd help


 
Thread Tools Search this Thread
# 1  
etc/passwd help

Hi!
i've been searching a way to display the users who are in the /etc/passwd directory...using ls or grep or cat command should do it?i can't find a way to get this right..i mean none of the preview commands function sounded good to me to use...
# 2  
Code:
awk ' { print $1 } ' /etc/passwd

# 3  
thanks a lot for your reply!maybe i didn't wrote what i want properly sorry for my bad english...my main problem is how i can use one of the commands(ls,cat,grep(or egrep)) to get the users in /etc/passwd.
any ideas??
thanks again for your reply!
# 4  
'get the users' can mean different things
list users
Code:
awk -F ':'  '{ print $1}'  /etc/passwd

find if a user exists, ex: username exactly = john
Code:
grep ':john:'  /etc/passwd | awk -F':' '{print $1}'

find users with john in the name
Code:
awk -F':' '{print $1}' /etc/passwd | grep 'john'

[/code]
# 5  
yeah i'm sorry!i mean the list of users...sorry!what about ls command or cat to get the list of users?is it possible?
# 6  
ls shows directory contents (files) not users. Not the content of files, just information like filename, size, who owns it, and file permissions

cat displays a file, with no special formatting. /etc/passwd is a colon delimited file, meaning each field (username, uid, gid, etc) is delimited or set apart by the colon character. frappa's answer gave you the same result that you will get from cat /etc/passwd, a mess of stuff on the screen.

You need to find and carefully read a basic UNIX reference on the internet, your absolute best choice would be one in your native language.
This User Gave Thanks to jim mcnamara For This Post:
# 7  
/etc/passwd is a file not a directory.
To see the properties of the file /etc/passwd :
Code:
ls -lad /etc/passwd

The easiest way to list the users is to use the unix "listusers" command. However your post suggests only using only basic commands.
A list of user names:
Code:
cut -f1 -d: /etc/passwd

This User Gave Thanks to methyl For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #643
Difficulty: Easy
From the beginning, the operating system of NeXTSTEP was built upon Mach/BSD.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passwd -s

Hi, I've a problem regarding understanding of result of passwd -s command. > passwd -s abc PS 05/24/12 0 441 I'm not a super user. But i need to write a simple code for checking password expiry and send an email to the team id. Is there any other command or way to achieve this?... (6 Replies)
Discussion started by: sam_bd
6 Replies

2. AIX

When did AIX start using /etc/security/passwd instead of /etc/passwd to store encrypted passwords?

Does anyone know when AIX started using /etc/security/passwd instead of /etc/passwd to store encrypted passwords? (1 Reply)
Discussion started by: Anne Neville
1 Replies

3. UNIX for Dummies Questions & Answers

passwd

Hello , how to open utemp,getpwuid files.I know what info these files will carry but i dont know ow to open see the info present in it. Thanks to help. (4 Replies)
Discussion started by: kkalyan
4 Replies

4. Solaris

passwd cmd reenables passwd aging in shadow entry

Hi Folks, I have Solaris 10, latest release. We have passwd aging set in /etc/defalut/passwd. I have an account that passwd should never expire. Acheived by emptying associated users shadow file entries for passwd aging. When I reset the users passwd using passwd command, it re enables... (3 Replies)
Discussion started by: BG_JrAdmin
3 Replies

5. Shell Programming and Scripting

/etc/passwd

Hello All I want to print only the full name from the /etc/passwd file and print it to the screen . Could you please let me know how can I do that? (4 Replies)
Discussion started by: supercops
4 Replies

6. Shell Programming and Scripting

wc /etc/passwd

I have left unix for a long time.Almost forget everthing.:( Anybody can tell me what is the meaning? wc /etc/passwd 9 16 1155 /etc/passwd and $ wc -l /etc/passwd wc -l /etc/passwd 9 /etc/passwd (1 Reply)
Discussion started by: zhshqzyc
1 Replies

7. HP-UX

passwd

Dear frnds, I have 250 users in passwd file with different passwords, how i can change the password to username+99. pls help out. regards (6 Replies)
Discussion started by: jestinabel
6 Replies

8. UNIX for Advanced & Expert Users

no /etc/passwd

Hello ppl, A small mistake of mine has led the /etc/passwd file deleted. So i went to rescue mode and used the following command echo "root::0:0:Superuser:/:/bin/bash" > passwd but that did not get effect in anyway way. when I switch back to normal mode the root is still asking for a passwd.... (3 Replies)
Discussion started by: cyno
3 Replies

9. UNIX for Dummies Questions & Answers

etc/passwd

Can anyone explain the second and third fields in /etc/passwd. Thanks. (2 Replies)
Discussion started by: nguda
2 Replies

10. UNIX for Dummies Questions & Answers

passwd

hello, I don't why I can't change the password, when ever I try to run passwd I get the problem??!!! unixws1:ldb> passwd passwd: Changing password for ldb Permission denied regards, me (2 Replies)
Discussion started by: geoquest
2 Replies

Featured Tech Videos