TrumanWong

grpck

Used to verify the integrity of group files

Supplementary instructions

grpck command is used to verify the integrity of group files. Before verification, the group files /etc/group and /etc/shadow need to be locked (lock).

The grpck command checks whether the data is stored correctly, whether each record contains enough information, whether it has a unique group name, whether it contains the correct user, whether the group administrator is correctly set, etc. After grpck detects errors, it prompts the user on the command line whether to delete the wrong records. If the user does not explicitly respond to delete the record, grpck terminates the operation.

grammar

grpck(option)

Options

-r: read-only mode;
-s: Sorting group id.

Example

Verify group accounts and shadow files:

grpck # must be run as administrator
grpck /etc/group /etc/gshadow # The next two sentences are the same. If no information is output, it means there is no error.

Example of test error:

**echo check_user❌ >> /etc/group # Add a line of incorrect format data
cat /etc/group | grep check_user**
check_user❌ # The GID field here is empty, which is wrong.

  **grpck /etc/group**
invalid group file entry
delete line 'check_user❌'? y # Prompt whether to delete
grpck: the files have been updated # The wrong line has been deleted, indicating that the file has been updated.

  **cat /etc/group | grep check_user # Not found, deleted. **