User and Group Management
Created Sunday 06 December 2009
id <user> ~ get all info (inc userID and groupIDs for a user)
USER MANAGEMENT
cat /etc/passwd ~ view all users
useradd <username> ~ add a new user (and create them a home directory in /home)
passwd <user> ~ reset a user's password
userdel <user> ~ delete a user
GROUP MANAGEMENT
cat /etc/group ~ view all groups (and their associated users)
groups <user> ~ view a user's groups
groupadd <groupname> ~ add a new group
ADD A USER TO A GROUP
usermod -aG <group> <user> ~ add user to group with (group could be comma separated list. -a is append, so doesnt remove other groups. -G is specify group name)
REMOVE A USER FROM A GROUP
-currently best way i can find to remove a user from a group is to find out which groups they currently belong (as specified above), then use the usermod command without the -a (meaning append), and then you can completely re-define all the groups you want for that user e.g. if user jack is in the following 3 groups: users, tomcat, apache, and you want to remove them from the tomcat group, you would do usermod -G users,apache jack