Monday, July 17, 2006

Users and Groups

I hate searching for this every time I have to add a user to a group. I keep forgetting the commands!

1. To view the list of groups and their users: $ cat /etc/group

2. Create new user: $ useradd

3. Create new group: $ groupadd.

4. To list all groups to which the user is a member: $ groups <user id> ## This is the one I keep forgetting!!!!

5. Add user to group z.B. cdrom: $ usermod -G <comma separated group list> <user id>
### Be sure to list all groups as this is an absolute list and not an addition. THIS IS IMPORTANT. Use the 'groups' command and then enter all the groups in addition to the new one under usermod.

EDIT: No need to list all the groups. I just found out that you can append the user to a supplementary group by using the -a option. Meaning:

usermod -a -G wireshark user

This will add 'wireshark' to the user's groups in addition to the other groups that the user already belongs to.

or

gpasswd -a username group


This is a usefule website.

No comments: