- Root User - It is the super user which can run any command generally used for administration.
- System User - Users needed for system specific operation/components, like mysql user to run mysql.
- Normal User - Other users which are created by root and have limited access given to them.
- User Type: Super user
- User Name: root
- User ID: 0
- Group ID: 0
- Home Directory: /root
- Shell: /bin/bash
User Management In Linux
- /etc/passwd - Keeps user account and password information.
- /etc/shadow - Keeps the encrypted password of the corresponding account
1. Add a user:
# useradd user1
2. Assign a password to a created user:
# passwd user1
3. Create user with account expiry date:
# useradd -e 2018-04-01 user2
4. Create a user with specific user id
# useradd -u 5111 user3
5. Create a user with specific user id and group id (Group Id must be present already)
# useradd -u 6111 -g 1000 user4
6. Add user to Multiple groups (user5 is being created and added to sudo and user1 group)
# useradd -G sudo,user1 user5
7. Add user with comments:
# useradd -c”Deverloper” user6
# tail -1 /etc/passwd
8. Add user with home directory
# useradd -m -d /home/user7 user7
# tail -1 /etc/passwd
1. Deleting existing user:
# userdel user1
2. Delete user forcefully, even if the user is logged in
# userdel -f user2
3. Delete user with home directory
# userdel -r user7
1. Changing home directory of a user:
# useradd -d /home/user7 user7
# usermod -d /home/appychip user7
2. Changing Primary group of a user:
# usermod -g sudo user4
3. Lock(-L) and Unlock(-U) users
# usermod -L user5
# usermod -U user5
Verify in /etc/shadow if an ! mark is present in front of user name. If present then user is locked.
After unlock it will disappear
4. Changing login name and password (xyz is new username and user6 is existing user)
# usermod -l xyz user6
# usermod -p p@ssWord xyz
5. View Account raging information:
# chage -l xyz
6. Changing password parameters:
# chage xyz
Enter a new value