⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch22_16.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 22] 22.16 Copying Permissions with cpmod </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:40:37Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch22_01.htm"TITLE="22. File Security, Ownership, and Sharing"><LINKREL="prev"HREF="ch22_15.htm"TITLE="22.15 Juggling Permissions "><LINKREL="next"HREF="ch22_17.htm"TITLE="22.17 Ways of Improving the Security of crypt "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_15.htm"TITLE="22.15 Juggling Permissions "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 22.15 Juggling Permissions "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 22<BR>File Security, Ownership, and Sharing</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_17.htm"TITLE="22.17 Ways of Improving the Security of crypt "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 22.17 Ways of Improving the Security of crypt "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-9025">22.16 Copying Permissions with cpmod </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-24676"></A><ACLASS="indexterm"NAME="AUTOID-24678"></A><ACLASS="indexterm"NAME="AUTOID-24681"></A>A utility to help facilitate permission juggling is <EMCLASS="emphasis">cpmod</EM>.This program lets you copy the group ownership and permission modesof one file to another.</P><PCLASS="para">For example, suppose you just <SPANCLASS="link">juggled permissions (<ACLASS="linkend"HREF="ch22_15.htm"TITLE="Juggling Permissions ">22.15</A>)</SPAN>using <EMCLASS="emphasis">chmod</EM> and <EMCLASS="emphasis">chgrp</EM>to give another user access to a file called <EMCLASS="emphasis">ch01</EM>, and now she wants permission for three more files in the same directory.You could repeat the process, or you could just use <EMCLASS="emphasis">cpmod</EM>to copy the permissions from the first file:</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist">&#13;<ACLASS="co"HREF="ch15_02.htm"TITLE="15.2 Filename Wildcards in a Nutshell ">[..]</A> &#13;</PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">&#13;% <CODECLASS="userinput"><B>ls -lg ch01</B></CODE>-rw-rw----  1 lmui     authors        13727 Sep 21 07:43 ch01% <CODECLASS="userinput"><B>ls -lg ch0[234]</B></CODE>-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% <CODECLASS="userinput"><B>cpmod ch01 ch0[234]</B></CODE>% <CODECLASS="userinput"><B>ls -lg ch0?</B></CODE>-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</PRE></TD></TR></TABLE></P><PCLASS="para">Use <EMCLASS="emphasis">cpmod</EM> to say, &quot;Make these files just like this other one.&quot;</P><PCLASS="para">In this example, we used it to quickly give write permissionto several files at once.But notice thatthe new files also inherit the same modification times.This is another feature of <EMCLASS="emphasis">cpmod</EM>, which comes in useful for programmers and other users of <SPANCLASS="link"><EMCLASS="emphasis">make</EM> (<ACLASS="linkend"HREF="ch28_13.htm"TITLE="make Isn't Just for Programmers! ">28.13</A>)</SPAN>.The <EMCLASS="emphasis">make</EM> program uses modification dates on filesto determine whether it should recompile source code. <EMCLASS="emphasis">cpmod</EM>provides a way to manipulate the modification dates when you need to.Article<ACLASS="xref"HREF="ch21_07.htm"TITLE="Setting File Modification Time with touch ">21.7</A>explains the version of the <EMCLASS="emphasis">touch</EM> command that can set a fileto have any modification date.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">LM</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_15.htm"TITLE="22.15 Juggling Permissions "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 22.15 Juggling Permissions "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch22_17.htm"TITLE="22.17 Ways of Improving the Security of crypt "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 22.17 Ways of Improving the Security of crypt "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">22.15 Juggling Permissions </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">22.17 Ways of Improving the Security of crypt </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -