Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

So there's chown which lets you change the owner and group of files and/or directories. But there's also chgrp which only changes the group. Why was chgrp created? Isn't it redundant?

share|improve this question
    
You can refer to the link here for more information. serverfault.com/questions/462174/… –  Ramesh Jun 13 at 16:49

1 Answer 1

up vote 28 down vote accepted

chown initially couldn't set the group. Later, some implementations added it as chown user.group, some as chown user:group until it was eventually standardised (emphasis mine):

The 4.3 BSD method of specifying both owner and group was included in this volume of POSIX.1-2008 because:

There are cases where the desired end condition could not be achieved using the chgrp and chown (that only changed the user ID) utilities. (If the current owner is not a member of the desired group and the desired owner is not a member of the current group, the chown() function could fail unless both owner and group are changed at the same time.)

Even if they could be changed independently, in cases where both are being changed, there is a 100% performance penalty caused by being forced to invoke both utilities.

Even now, chown :group to only change the group is not portable or standard.

chown user: (to assign the primary group of the user in the user database) is not standard either.

share|improve this answer
2  
@dayuloli, thanks for the edit, but I didn't include that section of the spec because I don't understand it –  Stéphane Chazelas Jun 14 at 8:09
    
Good question! Upvoted! –  dayuloli Jun 14 at 11:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.