Details of /etc/passwd file format

In linux user details are stored at “/etc/passwd” file. Whenever we create the new user in our system/server the new user and user details will be added to “/etc/passwd” file. The passwd file contain each/every user details as a single line with seven fields. While creating new users the below four file modified.

a) /etc/passwd – User details updated
b) /etc/shadow – User password updated
c) /etc/group – Group details updated of the new user
d) /etc/gshadow -Gropu password updated of the new user

1) How to view the user list

You can use the cat command to print the list of users created on your system/server. See the output below.

[email protected] [~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
2gadmin:x:500:10::/home/viadmin:/bin/bash
apache:x:48:48:Apache:/var/www:/sbin/nologin
zabbix:x:498:499:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin
mysql:x:497:502::/home/mysql:/bin/bash
zend:x:502:503::/u01/zend/zend/gui/lighttpd:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/cache/rpcbind:/sbin/nologin
2daygeek:x:503:504::/home/2daygeek:/bin/bash
named:x:25:25:Named:/var/named:/sbin/nologin
mageshm:x:506:507:mageshm:/home/mageshm:/bin/bash

The above output is clearly shows every line contain seven fields and every fields separated by comma “:”

2) Details of seven field

See the seven fields details of passwd file.

[email protected] [~]# grep "mageshm" /etc/passwd
mageshm:x:506:507:mageshm:/home/mageshm:/bin/bash
------- - --- --- ------- ------------- ---------
   1    2  3   4     5          6           7

3) Explanation of seven fields

See the explanation of seven fields.

  1. Username (mageshm) : Username of created user. Characters length should be between 1 to 32.
  2. Password (x) : It’s indicates that encrypted password is stored at /etc/shadow file.
  3. User ID(506) : It’s indicates the user ID (UID) each user should be contain unique UID. UID (0-Zero) is reserved for root, UID (1-99) reserved for system users and UID (100-999) reserved for system accounts/groups
  4. Group ID (GID) : It’s indicates the group ID (GID) each group should be contain unique GID is stored at /etc/group file.
  5. User ID Info (mageshm) : It’s indicates the command field. This field can be used to describe the user information.
  6. Home directory (/home/mageshm) : It’s indicates the user home directory.
  7. Command/shell (/bin/bash) : It’s indicates the shell directory.

4) How to check passwd file permission

The permission of “passwd” file is read only to users(-rw-r–r–) and root is the owner of file.

[email protected] [~]# ls -la /etc/passwd
-rw-r--r--. 1 root root 2834 Nov 19 10:11 /etc/passwd

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...