The /etc/password file is very important on Unix systems because it stores information about all the user accounts in the system.
It is readonly, the users can read the file, but not to modify it, unless they have superuser priviledges.
$ ls -l /etc/passwd
-rw-r--r-- 1 root root 1667 2012-06-01 17:31 /etc/passwd
$ < /etc/passwd less
has a separate line for each user. These lines have 7 fields, delimited one from another by colons (:).
Sample /etc/passwd line:
$ < /etc/passwd grep razvan
The fields are in the following order:
- Username – the username is the user’s login name.
- x – the x character indicates that the encrypted password is stored in /etc/shadow ; if you see ! instead of x, that means the user is not allowed to login in the system. (usually, the root in Debian based distros is not allowed to login).
- UID (User ID) – each user has assigned an ID. root has UID 0, the UIDs 1 – 999 are reserved for the system, and the first user you create (usually when installing Linux) in the system has the UID 1000;
- GID (Group ID) – each group has it’s own ID; the primary group is stored in /etc/group
- comment field ; also called as GECOS – these field can be empty; it stores information about the user, such as real name, telephone number, room number, etc.
- Home directory – the path to the user’s homedir ; by default in Linux, the homedir is in /home/username.
- Login shell – the path to the login shell; usually /bin/bash, but it can also be another application, instead of a shell (ex: /usr/bin/vim)
I recommend you to avoid editing the /etc/passwd file by hand, unless you know what you are doing.