Live as if you were to die tomorrow. Learn as if you were to live forever.

Saturday, 24 January 2015

Information about /etc/passwd file in linux/unix

The /etc/passwd file contains the list of all the users in Linux/Unix. It also contains some information related to the user. 

For example, the uid (user id) and gid (group id) of the user, home directory of the user, comment and login shell of the user.

The /etc/passwd file contains the information as shown below
This file contains 7 columns separated by colon (:)

1st column: Contains the list of the user.
2nd column: Contains x which means that password is stored in encrypted format in /etc/shadow file.
3rd column: Contains the user id
4th column: Contains the group id
5th column: It contains the information related to the user
6th column: It contains the home directory of the user
7th column: The last column contains the login shell of the user.

root user having 0 uid and gid. 1-499 uid is reserved for system user and 500 and more contains the uid or gid for normal users. 

usermod command is used to modify the fields in /etc/passwd file.