On a standard Linux distribution (e.g. Ubuntu) there is usually
/etc/group-, where the second one is only readable by root.
man group only describes
Thus my question: What is the purpose of
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
It is a backup of the previous copy of the file that is version of the file before the last change. It is kept because it is very important file. You can delete it, but backups are a "good thing".
You can easily verify it. Try
# groupadd test # diff /etc/group /etc/group-
There are other files also that are backed up the same way viz.
All the user and group management utilities like
useradd, usermod, userdel, groupmod, groupdel etc. create/update these backup files after successful execution of the command.
I agree with @Sachin Divekar's answer that this is a "backup file" but I needed more information as to how the file is created and how its permissions are set. On CentOS6, running
usermod to change group membership was (re)creating /etc/group- with permissions of 0644 instead of "only readable as root" as described in the original question.
usermod (and all the other user/group management utilities mentioned by @Sachin Divekar) is part of the shadow-utils package (I found the sources for shadow-184.108.40.206) and after digging through the sources I found a #create_backup method in commonio.c (see it at github.com) that is used by all the user/group utilities. The backup file is named after the source file postfixed with a "-" (in this case, '/etc/group-'), and the permissions of the backup file are set to the permissions of the source file &'ed with 0664.
This explains whywhen /etc/group is chmod 0644after running
usermod to modify local group membership, /etc/group- is created if it doesn't already exist and it is chmodded to 0644.