In Linux can have multiple users. To manage multiple users effectively you need to know
how to handle a user account – add, delete, edit and suspend user account.
Add user account
To add an user from terminal you have to run command useradd
After adding user you will need to create password for user.
passwords for user are stored in /etc/passwd file.
Add user account with full user name
You can also provide full user name by using –c switch with useradd command.
useradd –c “Full username” username
useradd –c “ A Datt” adatt
Add user account with specified UID
Whenever user is created in Linux system an UID is assigned to it. This UID is generated by system. Also home directory is created for user – /home/username.
You can create a user with any custom UID specified. For creating UID for user you will have to use –c switch.
useradd –u 1572 username
useradd –u 1572 adatt
Add user account with account expiry date
An user account can be created with an expiry date. The default expiry date of any user is set to 0 i.e. user account will never expire.
For creating a user account with account expiry date, use switch –e. The expiry date is to given in YYYY-MM-DD format.
useradd –e YYYY-MM-DD username
useradd –e 2017-09-25 adatt
This user will expire on 25 September 2017
Add user account with password expiry date
For security reasons a admin may want user to change password after every few day. Linux has an inbuilt option where an user account can be created with an expiry date using chage command. For creating a user account with password expiry date, use switch –f. Post this date user account will be made inactive by system
useradd –f days username
useradd –f 45 adatt
Creating a user with a home directory other than default
To set home directory of an user to a non-default home directory, we will have to use switch –c.
useradd –d /home/xxxxx username
useradd –d /home/developer adatt