0

After working 15 years with Linux, I stumbled upon the command chgrp. Until now, I always used chown to change the ownership of a file, even if I only changed the group; for example

chown :www-data index.php

So I wonder if there is anything that chgrp can do what chown cannot do. IMHO, the man pages do not point to specific advantage.

rexkogitans
  • 1,329

1 Answers1

-1

Your example:

chown :group file

does not work (it may work on some platforms but is non standard). It usually at the same time changes the owner of the file.

Also note that the colon method in chown has been added approx. 25 years ago, while chgrp is much older.

schily
  • 19,173
  • Since it does not work that way on POSIX, it should not be mentioned, unless you like to create vendor lock ins. – schily Jul 18 '18 at 12:10
  • Since it is questionable what should be done in these corner cases, it is unlikely to be standardized. Using features that may create random results on various platforms is not a good idea, in special since there is a better and documented way. – schily Jul 18 '18 at 12:20
  • As long as people mention that something may cause problems I have no problems. BTW: as an example... I've seen many people advertizing that GNU tar supports incremental backups. Unfortunately these people do not mention that is does not support incremental restores (except for simple cases). Maybe you understand why I try to warn people on things that might cause problems. – schily Jul 18 '18 at 12:33
  • Oh I definitely understand, and I appreciate it; thanks for editing your answer! – Stephen Kitt Jul 18 '18 at 12:35