grpck Command in Linux with Examples

This tutorial explains Linux “grpck” command, options and its usage with examples.

grpck – verify integrity of group files

Description :

The grpck command verifies the correctness of the group definitions in the user database files by checking the definitions for all the groups or for the groups that are specified by the Group parameter. If more than one group is specified, there must be a space between the groups.

Note: This command writes its messages to stderr.

The following attributes are checked:

name- Checks the uniqueness and composition of the group name. The group name must be a unique string of 8 bytes or less. It cannot begin with a + (plus sign), a : (colon), a – (minus sign), or a ~ (tilde). It cannot contain a : (colon) in the string and cannot be the ALL or default keywords. No system fix is possible.
groupID- Checks the uniqueness and composition of the group ID. The ID must not be null and must consist of decimal digits only. No system fix is possible.
users- Checks the existence of the users that are listed in the group database files. If you indicate that the system must fix errors, it deletes all the users that are not found in the user database files.
adms- Checks the existence of the users that are listed as group administrators in the group database files. If you indicate that the system must fix errors, it deletes all the administrators that are not found in the user database files.
admin- Checks for a valid admin attribute for each group in the /etc/security/group file. No system fix is available.

advertisement
advertisement

Usage :

grpck { -n | -p | -t | -y } { ALL | Group … }

Options :

-n
Reports errors but does not fix them.
-p
Fixes errors but does not report them.
-t
Reports errors and asks if they must be fixed.
-y
Fixes errors and reports them.

Note: Join free Sanfoundry classes at Telegram or Youtube

Examples :

1. To verify that all the group members and administrators exist in the user database, and to report all the errors but not fix them, enter the following command:

# grpck  -n ALL

2. To verify that all the group members and administrators exist in the user database, and to fix all the errors but not report them, enter the following command:

# grpck  -p ALL

3. To verify the uniqueness of the group name and group ID defined for the install group, enter the following command:

advertisement
# grpck  -n install

Or,

# grpck  -t install

Or,

advertisement
# grpck  -y install

The grpck command does not correct the group names and IDs. Therefore, the -n, -t, and -y flags report problems with group names and group IDs, but do not correct them.

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.