Creating groups and users


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Creating groups and users
# 8  
Old 09-10-2012
Code:
tr ':' ' ' </etc/group | while read g x
do
 if [ "$g" = "$MY_TRIAL_GROUP" ]
 then
   echo "Used: $g $x" >&2
   break
 fi
done

# 9  
Old 09-11-2012
awk might be used too, but this would also miss group entries stored elsewhere than /etc/group.
Code:
awk -F: '$1 == "'$MY_TRIAL_GROUP'" {printf("Used: %s\n",$0)}' /etc/group

getent group was designed to avoid this issue, no need to handcraft incomplete solutions.
# 10  
Old 09-13-2012
Command id takes an ID not a Group (although some name them alike, they are two different name spaces). You can get all the IDs of a group with -G as described here: Man Page for id (linux Section 1) - The UNIX and Linux Forums

If you know nis or yp is in use, the data equivalent to /etc/passwd is 'niscat passwd' or 'ypcat passwd'. It includes the local /etc/passwd entries:
Code:
$ ypcat passwd|grep -i <my_id>
my_id:MY_ID@this_corp.com:6068:6900:David Pickett|MY_ID:/home_dir_path:/usr/bin/ksh
$

For group, there is 'niscat group' and 'ypcat group'. You can grep for groups and users.

Last edited by DGPickett; 09-13-2012 at 05:24 PM..
# 11  
Old 09-13-2012
Quote:
Originally Posted by DGPickett
Command id takes an ID not a Group (although some name them alike, they are two different name spaces).
Indeed, that's the reason why I'm suggesting to use getent which can search both the passwd and group database (beyond others).
Quote:
You can get all the IDs of a group with -G
More precisely, you get all the group IDs of a user with this command, which is not what the OP is asking for.
Quote:
If you know nis or yp is in use, the data equivalent to /etc/passwd is 'niscat passwd' or 'ypcat passwd'. It includes the local /etc/passwd entries
Are you sure of that ? IMHO, that would be a bug of Linux ypcat if it really does.
Quote:
Code:
$ ypcat passwd|grep -i <my_id>
my_id:MY_ID@this_corp.com:6068:6900:David Pickett|MY_ID:/home_dir_path:/usr/bin/ksh
$

That's a strange password field, I would expect "*" there.
Quote:
For group, there is 'niscat group' and 'ypcat group'.
But here again, they would likely miss /etc/group entries (at least if they work as specified/documented) and they would definitely miss ldap entries.
Quote:
You can grep for groups and users.
which is precisely what the OP wants to avoid.
# 12  
Old 09-17-2012
So, in a positive vein, what is the ldap equivalent of "ypcat passwd" and "ypcat group"? We could pile up all the possibilities inside parens in bash, feeding "| sort -u ".
# 13  
Old 09-18-2012
That would be ldaplist but Linux distributions are lacking this command .
I have found this implementation:
RPM resource ldaplist
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

Creating user groups that are persistent

Hi, I need to modify the user 'munfai' by adding it into groups bscs, oinstall, dba. I use this command as user root to add the user into the mentioned groups : # usermod -G bscs,oinstall,dba munfai I can thereafter see the id in the groups : # id munfai uid=258(munfai) gid=20(users)... (2 Replies)
Discussion started by: anaigini45
2 Replies

2. UNIX for Dummies Questions & Answers

Users in multiple groups?

Happy Thanksgiving Everyone!! I have a question about adding users to multiple groups. Thanks in advance Using Red Hat and here are the issues: Example: Users: Bob Mark Groups: SystemsAnalysts BusinessAnalysts If I am adding a user Bob to both groups (SystemsAnalysts and... (2 Replies)
Discussion started by: hansokl
2 Replies

3. Shell Programming and Scripting

users and groups /etc/group parsing

Hi, I have two little issues: 1) there is possible in sh to create a function who return a boolean value? 2)i have to verify if an user belongs to a group and i think it is needed to create a function which take two parameter and return a boolean value. in fact i have to parse /etc/group... (5 Replies)
Discussion started by: catalint
5 Replies

4. UNIX for Dummies Questions & Answers

List users and groups

Hi I am new to unix so hopefully someone can help. I need to list all the users I have in my unix enviroment (AIX) and the groups (primary and secondary) they belong to. Can anyone help? Many thanks in advance (2 Replies)
Discussion started by: m3y
2 Replies

5. Solaris

Removing users from groups

How do I remove a user from a group? I'm using the usermod command but its not working. I have a user "abc" who is a member of the groups root and other. I'm trying to remove him from the group "other" (using CLI) which is his secondary group but it's not working. How do I do this? Is there any... (11 Replies)
Discussion started by: the_red_dove
11 Replies

6. Solaris

Defaults number of users and Groups

Hi All, I would like know how many of default number of users and groups are there in solaris-10... Regards Tirupathi Raju (2 Replies)
Discussion started by: tirupathiraju_t
2 Replies

7. UNIX for Dummies Questions & Answers

Finding out all users and their UNIX groups??

Is there a way to find out all users and the UNIX groups they belong to?? :) (3 Replies)
Discussion started by: Hangman2
3 Replies

8. UNIX for Dummies Questions & Answers

users and groups

hi eveyone i've recently requested my unix admin to create a userid for 2 groups. He created the id and i can see it by grep "id" /etc/group. But when i login with that id into unix and try to cd that group it says permission denied. something like cd /groupname -- permission denied Can my admin... (1 Reply)
Discussion started by: sammet
1 Replies

9. Linux

listing users and groups

RH 7.2 I'm trying to list the users & groups on my machine. I found the lsuser & lsgroup commands but no associated man pages. I typed: lsuser I get --> Valid options are: -a So I typed: lsuser -a I get --> Valid options are: groups, home So I typed: lsuser -a groups I get -->... (2 Replies)
Discussion started by: jalburger
2 Replies

10. Cybersecurity

Users and groups

Hi, Is it possible that one user belongs to many groups, or the relation of user/group is 1/1?. Thanks Ramón (2 Replies)
Discussion started by: rsanz
2 Replies
Login or Register to Ask a Question