Friday 27 January 2012

USER MANAGEMENT (Redhat)



Understanding Users


Following are the types of users that normally come in a Linux OS.


1. Administrator  or Super User
2. Normal Users
3. Sys Users or Pop Users (Users that have no shell to log in into)
4. Network User


The information regarding users is normally stored in the file /etc/passwd.

Each entry in the passwd file has 7 fields as shown:

Username : X : UID : GID : GECOS : Home directory : Default shell


Username           - gives the name of the user
X                         - indicates whether the user has a password
UID                    - the User ID  ( 0 is for root user , 1-499 are pop users, greater than 500 are normal users)
GID                     - the Primary Group ID number
GECOS               - It is used to give comment or description for that user
Home Directory  - Specifies the home directory of the user
Default Shell       - Specifies the default shell the user gets


Each user has a primary group associated with it. When a user is created, a primary group of the user with the same name as that of the user is created.


Information regarding the group is contained in the field  /etc/group


Each entry in the group file contains 4 fields :


Groupname : X : GID : Members in the group




Adding Users


useradd  <username>  - Creates a user

passwd  <username>  -  Sets a password for the user

useradd -d <directory location>  <username>  - Creates a user and makes the directory specified, the user's  home directory.

useradd  -s  <shell>  <username>  -  Creates a user by specifying the default shell the user gets.


Modifying Users


usermod  -g  <groupname>   <username>   -   Change primary group of the user

usermod  -G  <groupname>   <username>   -   Change secondary group of the user


User Groups

groupadd  <groupname>   -   Creates a group

gpasswd  <groupname>    -   Set or change the password of a group

groups  <username>         -   Lists the groups of a user

groupdel  <groupname>      -   Deletes a group


Delete Users


userdel  <username>        -    Deletes a user

userdel  -r  <username>   -    Deletes a user along with the home directory of the user.


" To create a pop user  -  useradd  -s  /sbin/nologin  <username> "



No comments:

Post a Comment