Linux Password (/etc/passwd) & Group (/etc/group) Integrity File Checkers Commands

in Categories Howto, Linux, Tips last updated December 21, 2005

In old good Sun Solaris days, one can use test /etc/passwd file integrity with the pwck command. The pwck command scans the password file and notes any inconsistencies. The checks include validation of the number of fields, login name, user ID, group ID, and whether the login directory and the program-to-use-as-shell exist.

Linux commands to check and verify integrity of password files

Check integrity of group file /etc/group with the grpck command command:
# grpck
# echo $?

To check integrity of password file /etc/passwd and /etc/shadow file with pwck the command:
# pwck
Sample outputs:

user 'lp': directory '/var/spool/lpd' does not exist
user 'news': directory '/var/spool/news' does not exist
user 'uucp': directory '/var/spool/uucp' does not exist
user 'list': directory '/var/list' does not exist
user 'irc': directory '/var/run/ircd' does not exist
user 'gnats': directory '/var/lib/gnats' does not exist
user 'nobody': directory '/nonexistent' does not exist
pwck: no changes

These are very handy utility in case of problem. Read man page of pwck(8) and grpck(8) for more information.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):