Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux basic command-verify group file grpck

Shulou Source: shulou.com Published: 2022-06-02 07:02:38 11月17日 Update

Grpck

The grpck directive verifies the integrity of the group files "/ etc/group" and "/ etc/gshadow". The check includes the correct number of fields, a unique valid group name, a valid group identifier, a valid list of members and administrators, and corresponding entries in the "/ etc/gshadow" file. It is fatal to check the correct number of fields and unique group names. If the entry has the wrong number of fields, the user is prompted to delete the entire row. If the user does not answer affirmatively, all further checks will be bypassed. Prompts you to delete entries with duplicate group names, but the rest of the checks will still be done. All other errors are warnings and users are encouraged to run the groupmod command to correct them.

Commands that operate on the "/ etc/group" and "/ etc/gshadow" files cannot change corrupted or duplicate entries. In this case, grpck should be used to delete the violation entry.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Grpck [options] group

2. List of options

Option

Description

-- help

Show help documentation

-- version

Show command version

-r

Run in read-only mode

S

Use gid to sort group and gshadow

3. Configuration

The following configuration variables in "/ etc/login.defs" change the behavior of the tool:

MAX_MEMBERS_PER_GROUP (number), the maximum number of members for each group entry. When the maximum is reached, start a new group entry (line) in "/ etc/group" (with the same name, same password, and same GID). The default value is 0, which means that there is no limit to the number of members in the group. This feature (split grouping) allows you to limit the length of lines in a group file. This is useful for ensuring that the lines of the NIS group are no more than 1024 characters. If you need to enforce such restrictions, you can use 25. Note: split grouping may not support all tools (even in the Shadow tool set). You should not use this variable unless you really need it.

4. Files

/ etc/group, group account information.

/ etc/gshadow, security group account information.

/ etc/passwd, user account information.

5. Examples

1) check group information

[root@localhost david] # grpck / / check the group information and return without any errors

[root@localhost david] # echo $?

2) sort / etc/group

[root@localhost david] # tail-n 2 / etc/group / / View group information

Smmsp:x:51:

Webalizer:x:67:

User01:x:502:

Group02:x:999:

[root@localhost david] # grpck-s / etc/group / / sort by gid

[root@localhost david] # tail-n 2 / etc/group / / View information, sorted

User01:x:502:

Group02:x:999:

Nfsnobody:x:65534:

Tags: Information entries checks files commands users errors sorting valid same fields tools members accounts limits maximum variables names check groups prompts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux Docker macOS MariaDB