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.

Read more...

add user command linux, delete user command linux, add password in linux, create user password command in linux, change user password command linux

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

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

How to create user account in linux and how to change user name.

How to create user password in linux.

How to change user password in linux.


Firstly in the linux, you must be log in as root user, unless directed otherwise.

1. Add User in linux or Create a User Account in linux

To create a user account, you use the adduser command in linux, which has the form:

#adduser userid(username)

where userid specifies the name of the user account that you want to create. The command prompts you for the information needed to create the account.

Here's a typical example of using the command, which creates a user account named ritvik:

ritvik:~# 

adduser ajay

Adding user ajay...
Adding new group ajay (1001).
Adding new user ajay (1001) with group ajay.
Creating home directory /home/ajay.
Copying files from /etc/skel
Changing password for ajay
Enter the new password (minimum of 5, maximum of 8 characters)
Please use a combination of upper and lower case letters and numbers.
Re-enter new password:
Password changed.
Changing the user information for ajay
Enter the new value, or press return for the default

Full Name []:

Ajay Sharma

Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/n]

y

ritvik:~#

Notice that the lines where the password was typed were overwritten by the subsequent lines. Moreover, for security, passwords are not echoed to the console as they are typed.

Notice also that several of the information fields were omitted - for example, Room Number. You can specify such information if you think it may be useful, but the system makes no use of the information and doesn't require you to provide it.

The similarly named useradd command also creates a user account, but does not prompt you for the password or other information.

When the command establishes a user account, it creates a home directory for the user. In the previous example, the command would have created the directory /home/ajay. It also places several configuration files in the home directory, copying them from the directory /etc/skel. These files generally have names beginning with the dot (.) character, so they are hidden from an ordinary ls -a argument of ls to list the names of the files. The files are generally ordinary text files, which you can view with a text editor, such as ae. By modifying the contents of such files, you can control the operation of the associated application. For example, the .bashrc file controls the operation of the BASH shell. command. Use the

2. Change a User's Name in linux

You can change the name associated with a user account, by using the chfn command in linux:

#chfn -f name userid

where name specifies the new name and userid specifies the account to be modified. If the name contains spaces or other special characters, it should be enclosed in double quotes ("). For example, to change the name associated with the account ajay to sharma ajay, you would enter the following command:

#chfn -f "sharma ajay" ajay

3. Delete User command in linux or Delete User Account in linux

To delete a user account, use the userdel command in linux:

#userdel user

where user specifies the account to be deleted. If you want to delete the user's home directory, its files and subdirectories, use this form of the command:

#userdel -r user
NOTE:
Because deleted files can't generally be recovered, you should
backup potentially useful files before deleting a user account.

4. Create User Password and Change a User Account Password in linux

From time to time, you should change your password, making it more difficult for others to break into your system. As system administrator, you may sometimes need to change the password associated with a user's account. For instance, some users have a bad habit of forgetting their password. They'll come to you, the system administrator, seeking help in accessing their account.

To change a password, you use the passwd command in linux. To change your own password, enter a command like this one:

# passwd

This command changes the password associated with the current user account. You don't have to be logged in as root to change a password. Because of this, users can change their own passwords without the help of the system administrator. The root user, however, can change the password associated with any user account, as you'll see shortly. Of course, only root can do so - other users can change only their own password.

The passwd command initiates a simple dialog that resembles the following:


$ passwd

Changing password for ajay Old password: Enter the new password (minimum of 5, maximum of 8 characters) Please use a combination of upper and lower case letters and numbers. New password: Re-enter new password: Password changed.

Notice the restrictions governing the choice of password, which are designed to prohibit passwords that might be easily guessed. If you choose a password that violates these restrictions, the command will refuse the password, prompting you for another.

As the root user, you can change the password associated with any user account. The system doesn't ask you for the current password, it immediately prompts for the new password:

ritvik:~# passwd ajay
means
ritvik:~# passwd username

Changing password for ajay Enter the new password (minimum of 5, maximum of 8 characters) Please use a combination of upper and lower case letters and numbers.
New password: Re-enter
new password: Password changed.

Information on users is stored in the file /etc/passwd, which you can view using a text editor. Any user can read this file, though only the root user can modify it. If you selected shadow passwords, passwords are encrypted and stored in the file /etc/shadow, which can be read only by the root user.



Read more...

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP