add group command linux, delete group command linux, add user to group in linux, delete user from goup linux, create group command in linux

Wednesday, July 29, 2009

How to add group in linux or how to create group in linux.

How to delete group in linux or how to remove group in linux

How to add user to group in linux and how to delete user from group in linux.


There are various Linux Commands
that Linux uses groups to define a set of related user accounts that can share access to a file or directory. You probably won't often find it necessary to configure group definitions, particularly if you use your system as a desktop system rather than a server. However, when you wish, you create and delete groups and modify their membership lists.

1. Create a group command in linux

To create a new group, use the groupadd command in linux:

#groupadd group

where group specifies the name of the group to be added. Groups are stored in the file /etc/group, which can be read by any user but modified only by root.

For example, to add a group named ajay, you would enter the following command:

#groupadd ajay

2. Delete a group command in linux

To delete a group, user the groupdel command in linux:

#groupdel group

where group specifies the name of the group to be deleted. For example, to delete the group named ajay, you would enter the following command:

#groupdel ajay

3. Adding a member to a group

To add a member to a group, you use a special form of the adduser command:

#adduser user group

where user specifies the member and group specifies the group to which the member is added. For example, to add the user ajay01 to the group ajay, you would enter the following command:

#adduser ajay01 ajay

4. Remove a member from a group in linux or delete user from group in linux

Unfortunately, no command removes a user from a specified group. The easiest way to remove a member from a group is by editing the /etc/group file. Here's an excerpt from a typical /etc/group file:

users:x:100:
nogroup:x:65534:
bmccarty:x:1000:
ajay:x:1002:ajay01,ajay02,ajay03

Each line in the file describes a single group and has the same form as other lines, consisting of a series of fields separated by colons (:). The fields are:

Group name

The name of the group.

Password

The encrypted password associated with the group. This field is not generally used, containing an x instead.

Group ID

The unique numeric ID associated with the group.

Member list

A list of user accounts, with a comma (,) separating each user account from the next.

To remove a member from a group, first create a backup copy of the /etc/group file:

cp /etc/group /etc/group.SAVE

The backup can prove helpful if you modify the file incorrectly. Next, open the /etc/group file in a text editor. Locate the line that describes the group and delete the user name and the following comma, if any. Save the file, exit the editor, and check your work.

0 comments:

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP