Creating and managing groups in Linux is a helpful feature as there are a number of users and managing them through groups becomes relatively easy. The group command in Linux can make our work easy. In this article, we will be going through the group command in Linux along with various options available with it.
What is Linux?
Linux is the kernel of a computer operating system. It's a computer component that lets apps and users access the computer's peripherals to execute certain tasks. For example, the operating system (OS) sends instructions from an application to the central processing unit (CPU) of a computer (CPU). Before providing the results to the programme via the operating system, the processor completes the operation.
What is a group command?
Users and groups are part of user management in Linux; users interact with the system, while groups are logical frameworks for managing a group of users. Users are divided into numerous groups, with each group consisting of many users. Managing privileges such as security and authorization rights among multiple users is difficult. It's simple to handle them as a group with the group command. Give the username as an input, and it will return the major and secondary group members' names. If no names are supplied, the current user information will be printed. The syntax for this is:
$ group [option] [username]
–help
In a terminal, enter the –help command to output help information. It provides a brief description of the "groups" command as well as associated resources.
$ groups --help
id
To get information about a person and his or her groups, use the id options. The command will display the primary and secondary groups; the primary group will display the user and group id, while the secondary group will display the username:
$ id <user>
n and g
To output usernames of all groups instead of user ids, use the -n and G arguments together:
$ id -nG
getent
The getent command displays items from selected databases, allowing you to obtain a list of all groups:
$ getent group
If we pass the group name as an argument, we get the information related to that particular group
$ getent group <username>
–version
Use the –version options in Linux to verify the version of the groups command:
$ groups --version
Conclusion
In this article, we went through various options related to the groups command in Linux. We saw how we can get a list of groups, information of a particular group, usernames of groups, and get information about a user’s group.
Leave a Comment on this Post