ch{mod,grp,own} --reference=file

It never fails to surprise me how I can use a program almost every day and yet still stumble on to previously undiscovered options. Yesterday I discovered the ‘–reference=file’ option while reading the manpage for chmod. When used this option takes the current permissions of the specified file and applies them to the other files specified on the command line. It’s also accepted by chgrp and chown.

Note: If you’re going to use this in production please consider the potential race condition.