Saturday, May 9, 2020

Group Management in Linux


Group Management in Linux (CentOS7 /MINT RHEL7)


What is Group in Linux?
In Linux, a group is a collection of users. The main purpose of the groups is to define a set of privileges like read, write, or execute permission for a given resource that can be shared among the users within the groupUsers can be added to an existing group to utilize the privileges it grants.
When first time user account is created, a group with the same name is created.
By default created group with user
Other users can be added to the group later.
The primary purpose of groups is to define a set of privileges such as reading, writing, or executing permission for a given resource that can be shared among the users within the group.
There are two types of groups in Linux operating systems:
·         Primary group – When a user creates a file, the file’s group is set to the user’s primary group. Usually, the name of the group is the same as the name of the user. The information about the user’s primary group is stored in the /etc/passwd file.
·         Secondary or supplementary group - Useful when you want to grant certain file permissions to a set of users who are members of the group. For example, if you add a specific user to the docker group, the user will inherit the access rights from the group, and be able to run docker commands.
·          
·         Add a New Group


Displaying the groups an user is a member of
After adding the user to a supplementary group, you can verify that it now actually belongs to such group(s):
# groups [username]
# id [username]

How to Add an Existing User to a Group

To add an existing user to a secondary group, use the usermod -a -G command followed the name of the group and the user:
sudo usermod -a -G groupname username

How to Add an Existing User to Multiple Groups in One Command

If you want to add an existing user to multiple secondary groups in one command, use the usermod command followed by the -G option name of the group separated by , (commas):
sudo usermod -a -G group1,group2 username

How to Change a User’s Primary Group

To change a user primary group, use the usermod command followed by the -g option:
sudo usermod -g groupname username
 


  Deleting a group
To delete a group, you’ll want to use groupdel,
# groupdel [group_name]

 

How to Create a New User and Assign Groups in One Command

The following useradd command creates a new user named nathan with primary group users and secondary groups wheel and developers.
sudo useradd -g users -G wheel,developers nathan

 



Thursday, May 7, 2020

Crearing Users & Group in CentOS7 /RHEL

What is User?

Group is an object which is used to access computer resources (like file, directory and printer etc)

Types of User Accounts in Linux

  Default user in linux operating system
  most powerful
2) System User-
        Create by any application like Appache user create during appache server installation.
3) Normal User($)
  Create by root users with limited access rights
Permission with normal user rights user can work in linux operation system.
This user only create or delete by root user.
Step-1) Open terminal and type su command for access root user session (#).

Step-2) Type command as below mention
              #useradd username.

Step-3 Check whether the user is created using with /etc/passwd file

             #cat /etc/passwd

Note it RepresentUser1-USernamex-Password
1003-UID1003-GUID/home/user1-User1 horme directory/bin/bash-Shell