Monday, July 14, 2014

User Management in Linux

9:00 AM

Each user is associated with a unique numerical identification number called a user ID (UID). Likewise, each group is associated with a group ID (GID). A user who creates a file is also the owner and group owner of that file. The file is assigned separate read, write, and execute permissions for the owner, the group, and everyone else. The file owner can be changed only by root, and access permissions can be changed by both the root user and file owner.


Now we can create a user named linuxstorages and can see what all steps and files getting involved for creating a new user in linux.  


root@linuxstorages:~# useradd linuxstorages

root@linuxstorages:~#passwd linuxstorages
New password:
Repeat password:

The username is the only information required to add a new user; however, for exam prospective you should know some additional command-line arguments for useradd. The useradd command creates the account, but the account is locked.
To unlock the account and create a password for the user, use the command passwd [username]. By default, the user's home directory is created and the files from /etc/skel/ are copied into it.

User Administration Commands:

  • Useradd   - To create a User
  • Usermod  - To Modify user
  • Userdel    - To delete a user

While using above commands of creating a user it reflects to three files

  •   /etc/passwd
  •   /etc/group
  •  /etc/shadow


# Vi /etc/passwd  

linuxstorages:x:500:500:linux:/home/linuxstorages:/bin/bash
      |                |   |      |                     |                         |
     1               2  3     4      5              6                       7



1 Username: It is used when user logs in. It should be between 1 and 32 characters in length.

2 Password: An x character indicates that encrypted password is stored in /etc/shadow file.

3 User ID:  Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UID’s 
1-99 reserved for other predefined accounts. Further UID 100-999 are reserved for administrative and system accounts/groups.

4 Group ID (GID): The primary group ID (stored in /etc/group file)
User ID info: The comment field. It allow you to add extra information about the users such as user’s full name, phone number etc.

5 User ID Info: The comment field. it allow you to add extra informatio about the users such as user's full name, Phone number etc.
 
6 Home directory: The absolute path to directory the user will be in when they log in. If this directory does not exists then users directory becomes / .

7 Command / Shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Please note that it does not have to be a shell

# Vi /etc/shadow


linuxstorages:$!$nfsoadfnssdfasdfv*^$bosfs:14880:0:9999:7
     |                                     |                             |     |    |      |
    1                                    2                            3    4   5     6


1 User name: It is your login name.

2 Password: It your encrypted password. The password should be minimum 6-8 characters long including special characters/digits.

3 Last password change (lastchanged): Days since that password was last changed.

4 Minimum: The minimum number of days required between password change. The number of days left before the user is allowed to change password.

5 Maximum: The maximum number of days the password is valid (after that user is forced to change password)

6 Warn: The number of days before password is expire that user is warned that his/her password must be changed.

# Vi /etc/group

linuxstorages:x:503:linuxadmin,linuxusers
       |             |     |                 |      
      1            2    3                4     
 

1 Group Name: It is the name of the group. If you run ls –la command. You will see this name printed in the group field.

2 Password: Generally password is not used, hence it is empty. It can store encrypt password. This is useful to implement privileged groups.


3 Group ID (GID) : Each user must be assigned a group id. You can see this number in your /etc/passwd file.

4 Group list: It is a list user names of users who are members of the group. The user names must be separated by commas.

Whereas unprivileged users uid&gid will start from 500.

The uid&gid between 1-499 will be for system users and groups uid&gid for processing a system process.

Written by

1 comments :

  1. i have configured static IP and BIND DNS on Redhat 6.4 with this settings can i add cleint to my server. my cleint will be one of Linux OS. plz help me...

    ReplyDelete

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism