LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 06-24-2007, 12:35 PM   #1
armandino
Member
 
Registered: Oct 2005
Posts: 72

Rep: Reputation: 15
Listing the members of a group


I'm running Fedora Core6.
What is the console command with which I can list all the users belonging to a certain group?
 
Old 06-24-2007, 12:47 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

Have a look in /etc/group , or run the following (this would be for the group 'dave'):
Code:
egrep '^dave' /etc/group | awk -F ':' '{print $4}'
Dave
 
Old 06-24-2007, 01:17 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,962
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Not lazy enough ... ;}
Code:
awk -F: '/^dave/ {print $4}' /etc/group

Cheers,
Tink
 
Old 06-24-2007, 02:40 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
He he. Nice.
 
Old 06-24-2007, 06:10 PM   #5
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Quote:
awk -F: '/^dave/ {print $4}' /etc/group
Unfortunately, that doesn't print the prime suspect, dave like this...
Code:
awk -F: '/^fred/{print $1","$4}' /etc/group
 
Old 06-24-2007, 06:43 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,962
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
But then why would I want to print what I entered to begin with? I mean,
I know that I'm looking for group dave, and that there's (hopefully) only
going to be ONE group by that name ... of course, if I searched for adm
and there was an adm and an admin group I'd get them both ... hmmm ...


Oh well...

[edit]
Slightly more verbose but works around the issue described above ...
Use equality instead of a regex ;D


Code:
awk -F: '$1 == "nogroup" {print $4}' /etc/group
[/edit]


Cheers,
Tink

Last edited by Tinkster; 06-24-2007 at 06:47 PM. Reason: amendment
 
  


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
listing the members of a group bondoq Linux - Server 3 02-25-2007 05:10 PM
PAM - only allow domain group members to log on via ssh? humbletech99 Linux - Networking 3 01-24-2006 11:53 AM
all winbind members of same group paul_mat Linux - Networking 0 01-16-2006 05:46 PM
winbind: group members? eantoranz Linux - Software 0 11-01-2005 08:47 AM
Group members and rights EERookie Linux - Newbie 0 06-03-2004 08:19 AM


All times are GMT -5. The time now is 03:37 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