Skip to content

Instantly share code, notes, and snippets.

@Monmoy042
Last active July 29, 2021 05:01
Show Gist options
  • Save Monmoy042/b188870d70ab8275b8190c1822a0ed88 to your computer and use it in GitHub Desktop.
Save Monmoy042/b188870d70ab8275b8190c1822a0ed88 to your computer and use it in GitHub Desktop.
In this gist I am going to discuss about one of the important topics of linux system administration. This gist is all about the create user and group and some other policies of linux system.

Linux User & Group Administration

There are three types of user we can see in the linux system
1) root : 0
2) System User : 1-999
3) Regular user: 1000+

Show all the user info

tail /etc/paswd

Show all user's password info

tail /etc/shadow

Show a particular user info

grep [userName] /etc/passwd

Show the user in system

id root
id [regular user name]
id mail 
Here, mail is a system user

Create new user

useradd [userName]

Create user with a fixed UID

useradd -u [UID] [userName]

Add full name to a user profile

usermod -c "fullName" [userName]

Password change of an user

passwd [userName]

Remove password of an user

passwd -d [userName]

Delete a user

userdel [userName]

Delete user with all contents

userdel -r [userName]

Show group info

tail /etc/group

Show a particular group info

grep [groupName] /etc/group

Add group in the system

groupadd [groupName]

Create user and add user to an existing group

useradd -G [groupName] [userName]

Addign existing user to the group

usermod -G [groupName] [userName]

Add an user to multiple groups

usermod -G [groupName-1,groupName-2] [userName]

Add new group with fixed GID

groupadd -g [GID] [groupName]

Reset group name

groupmod -n [newGroupName] [oldGroupName]

Delete user from a group

gpasswd -d [userName] [groupName]

Delete a group

groupdel [groupName]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment