home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 22.15 Juggling Permissions Chapter 22
File Security, Ownership, and Sharing
Next: 22.17 Ways of Improving the Security of crypt
 

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:







[..]
 





% ls -lg ch01


-rw-rw----  1 lmui     authors        13727 Sep 21 07:43 ch01
% ls -lg ch0[234]


-rw-------  1 lmui     book           34020 Oct 15 11:13 ch02
-rw-r-----  1 lmui     acct           11207 Oct 13 09:49 ch03
-rw-r--r--  1 lmui     book           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 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.

- LM


Previous: 22.15 Juggling Permissions UNIX Power Tools Next: 22.17 Ways of Improving the Security of crypt
22.15 Juggling Permissions Book Index 22.17 Ways of Improving the Security of crypt

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System