pwck Command Examples in Linux

The pwck command checks the integrity of /etc/passwd and /etc/shadow, and grpck checks /etc/group and /etc/gshadow. They look for correct format, valid data, valid names, and valid GIDs (see the man pages for a complete list). When you run these with no options, they report both warnings and errors:

$ pwck
user 'news': directory '/var/spool/news' does not exist
user 'uucp': directory '/var/spool/uucp' does not exist
user 'www-data': directory '/var/www' does not exist
user 'list': directory '/var/list' does not exist

Add the -q option to report only errors:

$ pwck -q

pwck Command Examples in Linux

1. To verify integrity of password files:

# pwck 

2. To report errors only:

# pwck -q 

3. To execute the pwck command in read only mode:

# pwck -r

4. To sort entries in passwd and shadow file:

# pwck -s 

5. To get the help for pwck:

# pwck --help
Related Post