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 () 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:

 [..] 
% ls -lg ch01 -rw-rw---- 1 lmui authors 13727 Sep 21 07:43 ch01 % ls -lg ch0[234] -rw------- 1 lmui tutorial 34020 Oct 15 11:13 ch02 -rw-r----- 1 lmui acct 11207 Oct 13 09:49 ch03 -rw-r--r-- 1 lmui tutorial 29239 Oct 07 18:12 ch03 % cpmod ch01 ch0[234] % ls -lg ch0? -rw-rw---- 1 lmui authors 13727 Sep 21 07:43 ch01 -rw-rw---- 1 lmui authors 34020 Sep 21 07:43 ch02 -rw-rw---- 1 lmui authors 11207 Sep 21 07:43 ch03 -rw-rw---- 1 lmui authors 29239 Sep 21 07:43 ch04

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 developers and other users of make (). 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 explains the version of the touch command that can set a file to have any modification date.

- LM