22.16 Copying Permissions with cpmod
A utility to help facilitate permission juggling is cpmod . This program lets you copy the group ownership and permission modes of one file to another.
For example, suppose you just juggled permissions (22.15 ) using chmod and chgrp to give another user access to a file called ch01 , and now she wants permission for three more files in the same directory. You could repeat the process, or you could just use cpmod to copy the permissions from the first file:
Use cpmod to say, "Make these files just like this other one."
In this example, we used it to quickly give write permission to several files at once. But notice that the new files also inherit the same modification times. This is another feature of cpmod , which comes in useful for programmers and other users of make (28.13 ) . The make program uses modification dates on files to determine whether it should recompile source code. cpmod provides a way to manipulate the modification dates when you need to. Article 21.7 explains the version of the touch command that can set a file to have any modification date.