Users in Linux System Administration

05 Jan, 2019
Users are accounts that can be used to login into a system. Each user is identified by a unique identification number or UID by the system. All the information of users in a system are stored in /etc/passwd file. The hashed passwords for users are stored in /etc/shadow file.
Users can be divided into two categories on the basis of the level of access:
Superuser/root/administrator : Access to all the files on the system.Normal users : Limited access.
Superuser/root/administrator : Access to all the files on the system.
Normal users : Limited access.
When a new user is created, by default system takes following actions:
Assigns UID to the user.
Creates a home directory /home/.
Sets the default shell of the user to be /bin/sh.
Creates a private user group, named after the username itself.
Contents of /etc/skel are copied to the home directory of the new user.
.bashrc, .bash_profile and .bash_logout are copied to the home directory of new user.These files provide environment variables for this user’s session.
This file is readable by any user but only root as read and write permissions for it. This file consists of the following colon separated information about users in a system:
Username fieldPassword fieldAn `x` in this field denotes that the encrypted password is stored in the /etc/shadow file.The user ID number (UID)User’s group ID number (GID)Additional information field such as the full name of the user or comment (GECOS)Absolute path of user’s home directoryLogin shell of the user
Username field
Password fieldAn `x` in this field denotes that the encrypted password is stored in the /etc/shadow file.
An `x` in this field denotes that the encrypted password is stored in the /etc/shadow file.
The user ID number (UID)
User’s group ID number (GID)
Additional information field such as the full name of the user or comment (GECOS)
Absolute path of user’s home directory
Login shell of the user
Syntax:
[username]:[password]:[UID]:[GID]:[GECOS]:[home_dir]:[shell_path]

Example:
This file is readable and writable by only by root user. This file consists of the following colon separated information about password of users in a system:
User name fieldPassword fieldContains an encrypted password.A blank entry, {:: }, indicates that a password is not required to login into that user’s account.An asterisk, {:*:}, indicates the account has been disabled.Last Password ChangeThis field denotes the number of days since the date of last password change counted since UNIX time (1-Jan-1970).The minimum number of days after which the user can change his password.Password validityDenotes the number of days after which the password will expire.Warning periodDenotes the number of days before the password expiry date, from which the user will start receiving warning notification for password change.Account validityDenotes the number of days after which the account will be disabled, once the password is expired.Account disabilityThis field denotes the number of days since which the account had been disabled counted from UNIX time (1-Jan-1970).
User name field
Password field
Contains an encrypted password.A blank entry, {:: }, indicates that a password is not required to login into that user’s account.An asterisk, {:*:}, indicates the account has been disabled.
A blank entry, {:: }, indicates that a password is not required to login into that user’s account.
An asterisk, {:*:}, indicates the account has been disabled.
Last Password ChangeThis field denotes the number of days since the date of last password change counted since UNIX time (1-Jan-1970).
This field denotes the number of days since the date of last password change counted since UNIX time (1-Jan-1970).
The minimum number of days after which the user can change his password.
Password validityDenotes the number of days after which the password will expire.
Denotes the number of days after which the password will expire.
Warning periodDenotes the number of days before the password expiry date, from which the user will start receiving warning notification for password change.
Denotes the number of days before the password expiry date, from which the user will start receiving warning notification for password change.
Account validityDenotes the number of days after which the account will be disabled, once the password is expired.
Denotes the number of days after which the account will be disabled, once the password is expired.
Account disabilityThis field denotes the number of days since which the account had been disabled counted from UNIX time (1-Jan-1970).
This field denotes the number of days since which the account had been disabled counted from UNIX time (1-Jan-1970).
Syntax:
[username]:[enc_pwd]:[last_pwd_change]:[pwd_validity]:[warn_date]:[acc_validity]:[acc_disablity]

Example:
linux-command
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.