Add A New User To A Group
Add a new user called vivek to a group called vsftp, enter:
# useradd -G vsftp -d /data/home/v/vivek -m vivek
# passwd vivek
Where,
- -G vsftp : Add vivek to secondary group called vsftp. This group must exists on the system.
- -d /data/home/v/vivek : Path to the vivek’s home directory
- -m : Create the new user’s home directory if it does not already exist.
- vivek : Username / login nane
UNIX Add Existing User To A Secondary Group
Use usermod command to modify a user’s login definition on the system including group membership. For, example add user vivek to sales group, enter:
# usermod -G sales vivek
Add user tom to sales but also keep his existing membership of ftpusers, enter:
# usermod -G ftpusers,sales tom
UNIX Add Existing User To A Primary Group
Add jerry to sales primary group and change its existing group membership:
# usermod -g sales jerry