0

I would like assistance with something I have to do.

I need to verify if all users in passwd are also in shadow, if the primary group exists, if the homedir exists and if it belongs to the correct user/group. If something is wrong, it should output it to a new file, called for example "errors".

How can I implement a script that does this?

1 Answer 1

1

pwck is probably what you seek.

The pwck command verifies the integrity of the users and authentication information. It checks that all entries in /etc/passwd and /etc/shadow have the proper format and contain valid data. The user is prompted to delete entries that are improperly formatted or which have other uncorrectable errors.

Similarly, grpck verifies the integrity of the group information files.

The grpck command verifies the integrity of the groups information. It checks that all entries in /etc/group and /etc/gshadow have the proper format and contain valid data. The user is prompted to delete entries that are improperly formatted or which have other uncorrectable errors.

1
  • Thank you so much, it's exactly what I needed! Commented Jan 2, 2021 at 21:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .