User Management - useradd, usermod & gpasswd commands
user management:-
***************
creating a user with variants:
******************************
#useradd -u <custom UID> <username> --> to create a user with different UID
ex: #usseradd -u 14000 half
#useradd -c <description> <username> --> to create a user with description
ex: #useradd -c mommy maa
#useradd -g <primary group> <username> --> to create a user with existing primary group
ex: #useradd -g kxip pbj
#useradd -G <seconadry group> <username> --> to create a user and add the user to some secondary group
ex: #useradd -G tokyo red
#useradd -d <home dir> <username> -->> to create a user with different home dir
ex: #useradd -d /d1 public
#cd /d1
#cp /etc/skel/.* /d1/
#useradd -s <shell path> <username> --> to create a user with diffferent shell path
ex: #useradd -s /bin/sh blue
modifing a users existing:-
***************************
#usermod -u <custom ID> <username> --> to change UID of user
ex:#usermod -u 14500 half
#usermod -c <description> <username> --> to change the description
ex: #usermod -c mom maa
#usermod -g <primary group> <username> --> to change the primary group of user
ex: #usermod -g pbj pbj
#usermod -G <secondary group> <username> --> to change the user into secondary group
ex: #usermod -G csk red
#usermod -d <home dir > <username> --> to change the home dir of user
ex: #usermod -d /home/blue blue
#usermod -s <shell path> <username> --> to change the shell path of user
ex: #usermod -s /bin/bash public
#usermod -l <new username> <old user name> --> to change the username of a user
ex: #usermod -l pub public
#getent passwd public --> no output
#getent passwd pub --> to verify the username is changed
adding a user to group:-
***********************
#gpasswd -a <username> <group name> --> to add single user into group
ex: #gpasswd -a zafar pbj
#gpasswd -M <username1>,<username2> <group name> --> to add mmultiple users into a group (previously existing user will removed from that group)
ex: #gpasswd -M zafar,maa,tokyo,blue red
#getent group red --> to verify the users added into the group
#gpasswd -A <admin username> <group name> --> to make a perticulaar user a admin of group
ex:#gpasswd -A zafar red
delete a user from group:-
*************************
#gpasswd -d <username> <groupname> --> to delete a user from group
ex: #gpasswd -d tokyo red
#getent group red -> to verify
Comments
Post a Comment