Users Management:
/etc/passwd file
The file stored information about users as following
[username]:[x]:[UID]:[GID]:[Comment]:[Home directory]:[Default shell]
here x is stored user authendication / protected by shadowed (/etc/shadow).
/etc/shadow file
The shadow files contains account authendication or encripted password stored.
Adding Users:
The new user creation with display name, group name and directory.
# useradd -c “Dilliganesh K” -d /home/data -g linux -s /bin/bash ganesh
# grep ganesh /etc/passwd
# ganesh:x:1001:1001:Dilliganesh K:/home/data:/bin/bash
here -c is for display name, -d for user data stored directory, -g for group name. -s for shell with account.
more ever -e for expiration date for the user and -u for user ID to set as default stored first available ID.
Adding Password:
# passwd ganesh
Changing password for user ganesh.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
To lock user account
# passwd -l ganesh
Locking password for user ganesh.
passwd: Success
To unlock user account
# passwd -u ganesh
Unlocking password for user ganesh.
passwd: Success
To set expire date for user account
# usermod –expiredate 2018-08-10 dilliganesh
Modify Users:
To change user login name
# usermod -l dilliganesh ganesh
# grep dilliganesh /etc/passwd
dilliganesh:x:1001:1001:Dilliganesh K:/home/data:/bin/bash
To change user directory
# usermod -d /home/dilli dilliganesh
# grep dilliganesh /etc/passwd
dilliganesh:x:1001:1001:Dilliganesh K:/home/dilli:/bin/bash
To change account group from linux to hr
# grep hr /etc/group
hr:x:1002:
# usermod -g hr dilliganesh
# grep dilliganesh /etc/passwd
dilliganesh:x:1001:1002:Dilliganesh K:/home/dilli:/bin/bash
To Adding a user to a primary group and supplementary group
# usermod -g hr -G manager dilliganesh
# grep dilliganesh /etc/passwd
dilliganesh:x:1001:1002:Dilliganesh K:/home/dilli:/bin/bash
User Deleting:
To user deleting
# userdel -r dilliganesh