Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18th July 2005, 10:24 PM
azazel00 Offline
Registered User
 
Join Date: Jul 2005
Location: Puerto Rico
Age: 29
Posts: 27
Any way of listing users by groups?

Hello

Well this isnt really a problem, just some task I want to accomplish.
Im using Postfix to run my office's internal mail (Quite a few users). Im insterested in a way of listing every user in a group in order to facilitate the creation of aliases.

sort of like:

Code:
listusers clinicaldept

userx
usery
userz
So far I havent had much luck with some random commands I've been testing. But then again my linux skills are something to be ashamed of.

The closest I've got is listing all logged in users. Which turns out to be a list containing only my name. lol

Anyhelp will be appreciated.
All the best.
az
Reply With Quote
  #2  
Old 19th July 2005, 03:32 AM
Jman Offline
Registered User
 
Join Date: Mar 2004
Location: Minnesota, USA
Age: 27
Posts: 7,909
Groups are contained in the /etc/groups file. It looks ugly, the comma seperated list at the end is what you want.
Reply With Quote
  #3  
Old 19th July 2005, 03:49 AM
pushback Offline
Registered User
 
Join Date: Jun 2005
Location: Bay Area, California
Posts: 167
You will have to play with the formatting and it's probably not the most efficient method but I threw this together for you. Cut & paste it into a text file, then chmod 755 the file, then run it.


(sorry--but the forum suppressed the indents)



#/bin/sh
for i in `cat /etc/group`
do
GROUPNAME=`echo $i|cut -f1 -d ':' `
echo "Checking for Group $GROUPNAME members."
GID=`echo $i|cut -f3 -d ':' `
for j in `cat /etc/passwd`
do
USERGID=`echo $j|cut -f4 -d ':' `
if [ "$GID" = "$USERGID" ]; then
USERNAME=`echo $j|cut -f1 -d ":" `
echo "$USERNAME is in the $GROUPNAME group."
fi
done
echo " "
done

Last edited by pushback; 19th July 2005 at 06:20 AM.
Reply With Quote
  #4  
Old 19th July 2005, 04:39 AM
azazel00 Offline
Registered User
 
Join Date: Jul 2005
Location: Puerto Rico
Age: 29
Posts: 27
Thanks for the script mate.
Will post with results tomorrow.

Regards

PS. I think the [c.ode][/c.ode] tags might help with indents, not sure tho.

Last edited by azazel00; 19th July 2005 at 04:44 AM.
Reply With Quote
Reply

Tags
groups, listing, users

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Users & Groups (missing users?) visualocity Security and Privacy 1 25th August 2009 12:52 PM
users and groups error danrweki Using Fedora 1 4th March 2009 05:10 AM
Users/groups addr Using Fedora 2 25th January 2007 03:24 PM
Users and Groups in Apache dogbone Servers & Networking 3 13th January 2006 03:23 AM


Current GMT-time: 17:14 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat