nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

any way to view view ALL members of a group?

This is a discussion on any way to view view ALL members of a group? within the Ubuntu / Debian forums, part of the Linux Distribution category; The thing I learnt a few days ago is that users to whom this particular group is primary will not ...


Go Back   nixCraft Linux Forum > Linux Distribution > Ubuntu / Debian

Linux answers from nixCraft.


Ubuntu / Debian Discussion about Debian or Ubuntu Linux related problems.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 18-05-2008, 10:27 PM
guzenkov's Avatar
Junior Member
User
 
Join Date: May 2008
OS: Arch
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
guzenkov is on a distinguished road
Default any way to view view ALL members of a group?

The thing I learnt a few days ago is that users to whom this particular group is primary will not be listed in /etc/group and by groupmem command. However users' primary groups are listed in /etc/passwd. But how can I view all members (no matter whether it is primary or secondary to them) of the group?

Last edited by guzenkov; 18-05-2008 at 10:30 PM.
Reply With Quote
  #2 (permalink)  
Old 18-05-2008, 10:32 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

To print the groups a user is in use groups command. For example print all groupname vivek user belongs to:
Code:
groups vivek
Sample output:
Code:
vivek : vivek adm dialout cdrom floppy audio dip video plugdev scanner netdev lpadmin powerdev admin dba vboxusers
However, to find out all members of a group, type following
Code:
egrep "^groupname" /etc/group 
egrep "^adm" /etc/group 
egrep "^ftpusers" /etc/group
HTH
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 18-05-2008, 10:46 PM
guzenkov's Avatar
Junior Member
User
 
Join Date: May 2008
OS: Arch
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
guzenkov is on a distinguished road
Default please reread the question

/etc/group WILL NOT list users, to whom this groups is primary! It lists ONLY those users, to whom this groups is secondary.
Reply With Quote
  #4 (permalink)  
Old 18-05-2008, 10:57 PM
guzenkov's Avatar
Junior Member
User
 
Join Date: May 2008
OS: Arch
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
guzenkov is on a distinguished road
Default an example of the problem

Code:
[root@localhost ~]# useradd x -g users
[root@localhost ~]# egrep "^users" /etc/group
users:x:100:
[root@localhost ~]# id x
uid=502(x) gid=100(users) Gruppen=100(users)

Last edited by guzenkov; 18-05-2008 at 10:57 PM. Reason: typo
Reply With Quote
  #5 (permalink)  
Old 19-05-2008, 01:01 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

Try
Code:
 id -G -n username
The -G will print all group IDs and -n will print in human readable format.

Here is an example:
Code:
useradd rocky
id -Gn rocky
Create a secondary group called ftp
Code:
groupadd ftp
Add rocky to secondary group called ftp
Code:
usermod -a -G ftp rocky
Now print all membeship
Code:
id -Gn rocky
You should see rocky as primary and ftp as secondary group.
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.

Last edited by rockdalinux; 19-05-2008 at 01:05 AM.
Reply With Quote
  #6 (permalink)  
Old 19-05-2008, 01:20 AM
guzenkov's Avatar
Junior Member
User
 
Join Date: May 2008
OS: Arch
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
guzenkov is on a distinguished road
Default

Firstly, your examples work with supplementary groups, not primary as is required in my question. Secondly, you show to what groups user belongs, but the question is what users belong to the group.
Reply With Quote
  #7 (permalink)  
Old 19-05-2008, 01:34 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default Listing the Members of a Group

So you want command to print ALL members of a group. For example, if I type
somecommand GROUPNAME

It should print list of users in both primary and secondary group. Am i right? if so you need to write a small shell script to query both /etc/passwd and /etc/group. Lemme know so that I can come with something.

edit: Have you tried members command?

Code:
members  --all groupname
members  --all ftp
From the man page:
members is a program that sends a space-separated list of secondary and primary member names to its standard output.
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.

Last edited by rockdalinux; 19-05-2008 at 01:40 AM.
Reply With Quote
  #8 (permalink)  
Old 19-05-2008, 02:07 AM
guzenkov's Avatar
Junior Member
User
 
Join Date: May 2008
OS: Arch
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
guzenkov is on a distinguished road
Default is there a standard tool available in all distributions?

Thank you, rockdalinux.
It looks like you got it. I think members command does it, but the problem that I don't have such command in the repositories of neither Archlinux, nor madriva (the two distributions I currently work with). Thus it does not apply to them.
I will be really surprised if this simple task is not performed by some standard linux tool.
Reply With Quote
  #9 (permalink)  
Old 19-05-2008, 02:21 AM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

You are welcome.

You can grab source code from Debian repo - http://ftp.de.debian.org/debian/pool...90831-5.tar.gz and always compile it on any Linux distro.

Code:
wget http://ftp.de.debian.org/debian/pool/main/m/members/members_19990831-5.tar.gz
tar zxvf members_19990831-5.tar.gz
cd members-19990831/
make
./members groupname
make install
cd 
members ftp
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
Reply

Tags
groups , linux


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
MP3 player (Sansa View) Albion Ubuntu / Debian 1 02-05-2008 11:46 PM
How To View This Cbt And What To Do linuxqu Linux software 2 24-03-2008 07:09 PM
View log files under Linux sweta Getting started tutorials 0 30-05-2007 12:31 AM
What is the maximum number of members that a group can have? warren Linux software 4 29-03-2006 07:31 AM
View MRTG on webpage sueAnne Linux software 1 10-03-2005 12:12 PM


All times are GMT +5.5. The time now is 05:34 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38