LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-03-2004, 03:32 PM   #1
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Rep: Reputation: 15
displayng users and groups they are in


Greetings, I am running mandrake 9.1 webserver. Is there a quick way to list all my groups and users within the groups? I know a script would be nice but I am not that experienced in scripts yet. I just want to list all the users by PID and groups with GID. ANy quick thoughts on this?

Thanks..
 
Old 02-03-2004, 04:24 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Try this command. ....
Code:
cat /etc/passwd | awk -F: '{print $1" "$3" "$4}'
 
Old 02-04-2004, 08:05 AM   #3
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Original Poster
Rep: Reputation: 15
homey.. Thanks.. I got a list of names with I am guessing the GID tied in to the user. That will work. Can you tell me what the pipe info is? ex. awk -Fprint $1" "$3: "$4)' Thank you for the reply.
 
Old 02-04-2004, 08:33 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Thumbs up

Glad to help.

cat /etc/passwd | awk -F: '{print $1" "$3" "$4}'

Actually, I could have made it easier for you with something like this....

cat /etc/passwd | awk -F: '{print $1" UID="$3" GID="$4}'


awk -F: '{print $1" UID="$3" GID="$4}'


To break this down to english....

Awk is a relative of the penguin. I can't remember what it stands for but it's made to scan for patterns.

-F: this tells awk to use the : for a field separator instead of the normal space or tab. If you run the command: cat /etc/passwd without awk, you will get a better idea of the fields separated by the colon ( : )

print send the results to standard output ( the screen )

$1 says to print the information in the first field. In this case, it is the user name.

" " I put a space between the output fields so it would look better.


There you go. I have lots of fun coming up with more uses for awk and another neat tool called sed.
If you google, you can get lots of examples,

Last edited by homey; 02-04-2004 at 08:36 AM.
 
Old 02-04-2004, 08:52 AM   #5
AZDAVE
Member
 
Registered: Aug 2003
Posts: 82

Original Poster
Rep: Reputation: 15
Thank You Homey.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
groups and users twb2005 Linux - Newbie 7 10-10-2005 06:21 PM
users and groups twb2005 Linux From Scratch 2 10-10-2005 01:47 PM
users and groups twb2005 Red Hat 1 10-10-2005 01:47 PM
users and groups Red Squirrel Linux - Newbie 2 02-22-2004 07:37 PM
users and groups krfulton Linux - Security 1 01-05-2004 03:43 AM


All times are GMT -5. The time now is 08:01 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration