Mastering Linux User and Group Administration: Essential Commands for Devops.
User Administration Commands
1) Create a New User Account
#useradd user1
to chk user detail
#grep user1 /etc/passwd
#grep user1 /etc/shadow
2) Assign a Password to User
#passwd user1
give the password(2 times)
to chk
#grep user1 /etc/shadow
3) to change the age of user password
#chage user1
give the value as per the requirement
to chk
#grep user1 /etc/shadow
4) login as user
a) from root terminal
#su user1
Note: The user will log in to their own home directory(/root)
to chk
$pwd
to come out from user
$exit
another method
su - user1
Note: The user will login to their own home directory(/home)
to chk
$pwd
to logout from user
$logout
b) from graphical mode
#gdmflexiserver
click on username and give the password
then logout from user
c) from text mode
press Alt Ctrl F2
login give the name
password
then $logout
press Alt Ctrl F1 (to come to graphical mode)
5) Lock a User Account
#usermod -L u1
to chk the result
try to login as user by using
#gdmflexiserver
or press Alt Ctrl F2
try to log is user by giving the username and password
result: user cannot login
press Alt Ctrl F1 (to come to graphical mode)
6) Unlock a User Account
#usermod -U u1
to chk the result
try to lgin as user by using
#gdmflexiserver
or press Alt Ctrl F2
try to login as user
Result : the user can login
then logout from user
press Alt Ctrl F1 (to come to graphical mode)
7) Delete a User Account
#userdel -r u1
Group Administration Commands
1) Create a Group
#groupadd linux (group name)
to chk
hashtag#grep linux /etc/group
#grep linux /etc/gshadow
2) Assign Group Password
#gpasswd linux
give the passwd (2 times)
to chk
#grep linux /etc/gshadow
3) Create Users
#useradd user1
#useradd user2
#useradd user3
#useradd user4
4) Add Multiple Users to Group
#gpasswd -M user1,user2 linux
5) Add Single User to Group
#gpasswd -a user3 linux
to chk
#grep linux /etc/group
6) Delete User from Group
#gpasswd -d u2 linux
to chk
#grep linux /etc/group
7) Make User a Group Admin
#gpasswd -A u1 linux
to chk
#grep linux /etc/gshadow
Note: The group admin will get extra privileges like
adding or removing the users from group
(which normal group members cannot do)
8) Remove Group Admin
#gpasswd -A "" linux
to chk
#grep linux /etc/gshadow
9) Change Group ID
#groupmod -g 2018 linux
to chk
#grep linux /etc/group
10) Change Group Name
groupmod -n azure linux
to chk
#grep azure /etc/group
11) Delete Group
#groupdel azure
#Devops hashtag#Linux hashtag#AWS
share this post with your connections