LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-13-2006, 04:08 AM   #1
Akhran
Member
 
Registered: Aug 2005
Distribution: Debian 'lenny'
Posts: 208

Rep: Reputation: 30
Is there a command to show the the member(s) of a group?


'groups username' shows the group(s) the user belongs to. Is there a command to show the member(s) of a group?

Thanks !
 
Old 02-13-2006, 04:26 AM   #2
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 38
apropos group
gave me: man group
which points to:
cat /etc/group
It doesn't really give all info though, it does not say that i'm part of the users group which is weird ..
 
Old 02-13-2006, 04:32 AM   #3
scuzzman
Senior Member
 
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
Code:
grep group_name /etc/group
eg:
Code:
[scuzzy@slackdell /home/scuzzy]$ grep users /etc/group
users::100:scuzzy,nobody
[scuzzy@slackdell /home/scuzzy]$ grep music /etc/group
music:x:105:scuzzy
[scuzzy@slackdell /home/scuzzy]$
 
Old 02-13-2006, 04:34 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
grep '<group-name>' /etc/group

The members of a group are listed after the third colon.

In a script, you could do something like:
Code:
#!/bin/bash
sed -n "/${1}/s/.*:.*:.*://p" /etc/group
Set the executable bit, and copy it to your $HOME/bin/. Now you have the command you want. A comma seperated list of the members is printed.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Member of local and remote group at the same time? xtrax Linux - General 3 12-20-2004 07:36 PM
LQ member progress status from member to senior member............. emailssent LQ Suggestions & Feedback 3 10-11-2004 01:31 PM
Why does mysqld not show up w/ps command baandar Linux - Software 3 09-01-2004 02:21 AM
What command to show mandrake version? minorgod Linux - Software 4 07-05-2004 09:30 PM
Command 2 Show sys Spec Thom_Redhat Linux - General 1 11-11-2003 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration