Linux User and Group General Operations

# Add new user
useradd tomcruise

# Create new group
groupadd webadmins

# Add user to group
usermod -a -G webadmins tomcruise

# Assign a specific UID to user
usermod -u 2000 tomcruise

# Please note that all files which are located in the user's home directory will have the file UID changed automatically as soon as you type above command. Symlinks outside of the home directory will require manual chown to prevent access issues after the change. Here's the fix:
find / -user 2000 -exec chown -h tomcruise {} \

# Verify stuff
grep tomcruise /etc/passwd # Check Tom's UID
ls -l /home/tomcruise/ # Check Tom Cruise's home
id -u tomcruise # Check Tom's UID

# Assign a specific GID to group
groupmod -g 3000 webadmins

# Similar to changing UID, GID modifications will need to be followed up with this command:
find / -group 3000 -exec chgrp -h webadmins {} \

# Note that the necessary -h option on the chgrp/chmod commands affect symbolic links instead of their referenced files/directories.

# Verify groupies
id -g webadmins # Check webadmins' GID
grep tomcruise /etc/group # Check Tom's group assignment
Posted on Categories Linux

Leave a Reply

Your email address will not be published. Required fields are marked *