What are Linux groups ?
A group is a set of users, created to share files and to facilitate collaboration. The system administrator can add new groups and give users membership to the different groups, according to the users' organizational needs. On a Linux system, you're always a member of at least one group.
Groups are used in Linux for access control. The only user that has full access is the super user (ROOT).
Where we can find the group information ?
The /etc/group is the file that defines the groups on the system.
To display the group of a user we will use the command :
- if we do not use the "user name" option the current user group will be displayed.
How to create a new group in Linux
To create a new group we will use the "groupadd" command :
How can we add a new member to a group in Linux
For this we will use the "gpasswd" command :
Option
Except for the -A and -M options, the options cannot be combined.
The options which apply to the gpasswd command are:
Examples
- this command will add the user named "user1" to the group named "group1".
- this command will remove the user named "user1" from group named "group1". But will not delete the user.
How drop/delete a group in Linux
For this we will use the "groupdel" command :
- the group has to exist in order to drop it :).
How to give permissions to groups in Linux
After a group is created it has no permissions on anything so we need to create some for them.
For this we will use the "groupmod" command :
The groupmod command modifies the definition of the specified GROUP by modifying the appropriate entry in the group database.
groupmod - modify a group definition on the system
Syntax
bash:> groupmod [options] "group name"Options
Example
- this command will change the name of the group "group1" to "groupX".
For now this all about groups, in future tutorials we will go in more details about groups and how to set out default groups.