Linux user administration commands

Linux User Administration

Linux is a multi user and multitasking OS. In Linux, you can create any number of user account and groups. A user is always connected to a particular group and there can be any number of groups as well.

The user home directory by default is created under "/home" directory with the user name. e.g. User sun has home directory "/home/sun", the mail account is created under "/var/spool/mail/".

Each user and group in the system is identified by a unique no called as ID.

There are two types of user:

1) System users 
2) Normal users

The system users have ID values from 0 to 499  & the normal users can have ID values from 500 to 60,000.

The users and groups are maintained by the four databases files. These are:

1) /etc/passwd : This databases file maintains the user information like UID, GID, User name etc.
2) /etc/shadow : This file maintains user password related information like uname, encrypted pwd, etc. The pwd's are encrypted in the pwd binary file. To encrypt the passwords, MD5sum, DES algorithms are used.
3) /etc/group : It maintains group related information like group name, GID, etc.
4) /etc/gshadow : It maintains the group password related information. 

User administration :

For user administration five commands are used.

1) useradd : This command is used to create a new user with default values.
$useradd <options> <user-name>

where the options can be,

-U = User id
-g = group ID (primary)
-G = group ID (secondary)
-c = comment
-d = directory 
-s  = shell 
-f  = inactive days
-e = expire date (YYYY MM DD)
2) usermod : This command is used to modify the user accounts. Only the administrator can use this command. It's syntax is,
$usermod <options> <user-name>
where the options can be,        

-l = to change the user name
-L = to lock the user account
-U = to unlock the user account

3) passwd :  This command is used to generate the passwords for users account.
$passwd < user-name> 
To disable a password,
$passwd -d <user-name>

4) userdel : This command is used to delete a user account.
$userdel <user-name>

5) change : This command is used to change the password expiry information. 
$chage <user name>