Thursday, October 24, 2013

UNIX Script: Basic command to create/add users and groups

#create a user and set its password
useradd -m user
passwd user


#create a new group in unix
groupadd group

#create a user and add it to a group
useradd -g groupname -m user
passwd user


#add a user to multiple groups
usermod -G group1, group2, group3 user

#other user/group command
userdel
groupdel
groupmod


#Change name of a user (UID) and ownership of its folders (e.g, PS_HOME is owned by user psoft1, rename the user to psoft and PS_HOME ownership will change as well)
usermod -l <New Name> <Old Name>


#Change ownsership of directory and its subdirectories and files
chown -R user /path/to/dir

No comments:

Post a Comment