Thursday 16 June 2016

 08:25      No comments

 

 


 Group information is stored in the /etc/group file. Each record has the following format



[Group name]:[Group password]:[GID]:[Group members]

    [Group name] is the name of group.
    An x in [Group password] indicates group passwords are not being used.
    [GID]: same as in /etc/passwd.
    [Group members]: a comma separated list of users who are members of [Group name].


How to create a group.


To create group use groupadd commands. Group created by this command is called secondary group.
#groupadd test

#groupadd -g 600 -p pro@123 project1

g :gid
p: password
r : system account ( its take the gid value from reserved group id values)




How to add user in groups


To add user in this group use usermod commands

This command will make vinita user to member of test group BY REMOVING FROM ALL OTHER GROUP


#usermod –G test vinita


# usermod -a -G group1 vinita

The -a option is critical. The user is added to group1 while he continues to be a member of other groups. If it’s not used, then the user is added only to group1 and removed from any other groups. So, take note!
How to delete secondary group

You can delete a group by groupdel commands


# #groupdel test


You cannot delete users primary group until user exist for example

 #groupdel nikki


Remove a user from a group



Removing a user from a group is a bit trickier. Unfortunately, there is no direct command, at least not in Fedora or RHEL, that can do that from command line. At first you need to get a list of groups that your user is a member of:

# id -nG username
group1 group2 group3 ....

OR

# id username


Then you need to put all these groups as a comma-separated list to the usermod -G option, except for the group from which you want the user to be removed. So, to remove the user from group2, issue the command:

# usermod -G group1,group3,... username

0 comments:

Post a Comment

Popular Posts

Recent Posts

Unordered List

Categories

Text Widget

Powered by Blogger.

Home - PageNavi (show/hide)

Ads

Pages