Linux Administration ( part 2 ): creating/managing groups in Linux

HackPeas Freelancers
2 min readApr 17, 2022

What are Groups:

Groups in Linux are used to manage users and provide them a set of privileged permissions for reading, writing, and executing. by default Linux already has some groups such as sudo cdrom floppy audio dip video plugdev netdev bluetooth lpadmin scanner

Checking all groups of which a user is a member

we can use the following commands to do this:

$ groups username
hackpeas, Viraj Vaishnav, veer1024, Viraj1024

/etc/group

This particular file contains information regarding different groups and their members, and each line is written in the following format:

GROUP_NAME:x(WHICH_REPRESENT_PASSWORD_WHICH_IS_NULL):GROUP_ID:LIST_OF_ALL_GROUP_USERS_SEPARATED_BY_COMMA

or

GROUP_NAME:x(WHICH_REPRESENT_PASSWORD_WHICH_IS_NULL):GROUP_ID:ONE_USER_AND_FOR_OTHER_MEMBERS_OF_GROUP_SEPARATE_LINES_ARE_THERE

Creating new group

To create a group we can use groupadd command

$ groupadd [option] group_name

this command creates a new group with the name group_name, and also add its entry to /etc/group and /etc/gshadow

-> /etc/login.defs

whenever a new group is created, some of the default values are taken from this file

[options]

  • g integer ## to set specific GID
  • -K GID_MIN=1200 -K GID_MAX=1500 ## changing some default values from /etc/login.defs
  • -r ## use this to create a system group

$ groupadd -g 1005 grouptest

hackpeas , Viraj Vaishnav , Veer1024 , Viraj1024

Creating a testuser

Adding user to group

adding user testuser to group grouptest

$ usermod -aG GROUP_NAME USER_NAME
hackpeas, Viraj Vaishnav , veer1024, Viraj1024
$ usermod -aG grouptest testuser

Removing user from group

$ gpasswd -d USER_NAME GROUP_NAME

$ gpasswd -d testuser grouptest

For more CTFs and bug bounty writeup, or content related to ethical hacking, android penetration testing. follow me on:

Youtube: https://www.youtube.com/channel/UC17W_Ircv7EmIIdbJeOQ_BQ
Instagram: https://www.instagram.com/hackpeas/
Linkedin: https://www.linkedin.com/in/viraj-vaishnav-19b0a61aa/
Twitter: https://twitter.com/VirajVaishnav16

Thank You..

--

--

HackPeas Freelancers

We provide the best technical services on a reasonable budget