getting rid of excess groups

Christofer C. Bell christofer.c.bell at gmail.com
Wed May 15 07:50:19 UTC 2013


On Tue, May 14, 2013 at 7:33 PM, Ric Moore <wayward4now at gmail.com> wrote:

> On 05/12/2013 04:21 PM, Tom H wrote:
>
>> On Sun, May 12, 2013 at 8:35 AM, John R. Sowden
>> <jsowden at americansentry.net> wrote:
>>
>>>
>>> I seem to have groups for staff, me, another user, and others above and
>>> below 1000. I would like to get rid of the ones not used, but I need to
>>> know if they are used. How do I do this?
>>> Not only are they used by a program, but also are there files owned by
>>> those
>>> groups?
>>>
>>
>> You should read
>>
>> /usr/share/doc/base-passwd/**README
>> /usr/share/doc/base-passwd/**users-and-groups.txt.gz
>>
>> before deleting any system groups.
>>
>> You can use
>>
>> for G in $(awk -F: '!/root/ {print $1}' < /etc/group) ; do find /
>> -xdev -group "$G" ; done
>>
>> but it'll run find for every group on your system other than "root",
>> so you might want to copy "/etc/group" to another file and edit some
>> lines out - or "feed" the find command some other way.
>>
>> (Re-run the command if "/usr" or /var" or "..." is a separate filesystem.)
>>
> Or, he could just leave it the heck alone as it would be rare that there
> would be superfluous groups added. Even if one is completely idle, it
> wouldn't add 1/10th of a 'k' to system overhead to worry about.  The only
> way the OP can determine what to delete would be to comment it out, reboot
> and see what breaks and pray it isn't critical. <cackles> Ric


The total "waste" from leaving the default system groups alone is "nothing"
bytes of disk (the groups themselves take 618 bytes).  Since the default
block size is 4kb, and I'll lay any money you like /etc/group is under 4k
for this guy, removing them saves absolutely nothing, at all.  The file
will still take 4kb of disk, regardless of what ls -l tells you.

At any rate, the content of /etc/group doesn't "create" groups.  It's just
a mapping between group ID numbers and human readable names.  Deleting
group "adm" from /etc/group doesn't remove the group.  It just means files
that were owned by group bin are now owned by group "2".  One can "create"
a group by simply running chgrp on a file with any random number they
please in place of a group name.  Removing the mapping is silly.

Shoot, here's an example of that:

cbell at circe:~$ touch test
cbell at circe:~$ ls -l test
-rw-rw-r-- 1 cbell cbell 0 May 15 02:48 test
cbell at circe:~$ sudo chgrp 1492 test
cbell at circe:~$ ls -l test
-rw-rw-r-- 1 cbell 1492 0 May 15 02:48 test
cbell at circe:~$

There, like magic, I just created a new group out of thin air!

While I'm sure the OP's question is sincere, it's one that should be met
with education as to why the question is nonsensical rather than efforts to
"help" do what he's asking.

All just my opinion, of course!

-- 
Chris

"If you wish to make an apple pie from scratch, you must first invent the
Universe." -- Carl Sagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20130515/8bfe2924/attachment.html>


More information about the ubuntu-users mailing list