221-228.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 265 行
HTML
265 行
<HTML>
<HEAD>
<TITLE>Linux in Plain English:Linux Commands Organized by Group</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=1558285423//-->
<!--TITLE=Linux in Plain English//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=5//-->
<!--PAGES=221-228//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="217-221.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="229-232.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P><FONT SIZE="+1"><B><I>EXAMPLE USING NUMERIC FORM</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ chmod 764 pat.memo
</PRE>
<!-- END CODE SNIP //-->
<P>This command line combines <B>chmod</B> with a mode of 744, applied to the file <B>pat.memo</B>. This means that the owner can read, write, and execute the file (that’s what the <B>7</B> designates), the group can read the file and write to it, but not execute it, and the world can read the file but not execute it or write to it.</P>
<P>How do we arrive at <B>764</B>? Because we add up the numerical value of modes, which we’ll cover in the next sections. A mode number can range between <B>000</B> and <B>777</B>; <B>000</B> means that no one has any access to a file, while <B>777</B> means that everyone has full access to a file. Here’s the exact math used to arrive at <B>764</B>:</P>
<TABLE WIDTH="100%"><TR>
<TD WIDTH="20%"><B>400</B>
<TD WIDTH="80%">Owner has read permission.
<TR>
<TD><B>200</B>
<TD>Owner has write permission.
<TR>
<TD><B>100</B>
<TD>Owner has execute permission.
<TR>
<TD><B>040</B>
<TD>Group has read permission.
<TR>
<TD><B>020</B>
<TD>Group has write permission.
<TR>
<TD><B>004</B>
<TD>World has read permission.
<TR>
<TD><B>764</B>
<TD>(Total)
</TABLE>
<P>Using the <B>ls</B> command on the file in question, you’d see that it has the following permissions:</P>
<!-- CODE SNIP //-->
<PRE>
rwxrw-r--
</PRE>
<!-- END CODE SNIP //-->
<P><FONT SIZE="+1"><B><I>MODES</I></B></FONT></P>
<P>The mode is a combination of the following:
</P>
<TABLE WIDTH="100%"><TR>
<TD WIDTH="20%"><B>400</B>
<TD WIDTH="80%">Owner has read permission.
<TR>
<TD><B>200</B>
<TD>Owner has write permission.
<TR>
<TD><B>100</B>
<TD>Owner has execute permission.
<TR>
<TD><B>040</B>
<TD>Group has read permission.
<TR>
<TD><B>020</B>
<TD>Group has write permission.
<TR>
<TD><B>010</B>
<TD>Group has execute permission.
<TR>
<TD><B>004</B>
<TD>World has read permission.
<TR>
<TD><B>002</B>
<TD>World has write permission.
<TR>
<TD><B>001</B>
<TD>World has execute permission.
</TABLE>
<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>
<TABLE WIDTH="100%">
<TR>
<TD WIDTH="20%"><B>-c</B>
<TD WIDTH="80%">Prints information about the changes made.
<TR>
<TD><B>-f</B>
<TD>Ignores information about files that can’t be changed.
<TR>
<TD><B>-v</B>
<TD>Verbose mode, where changes and failed changes are listed.
<TR>
<TD VALIGN="TOP"><B>-R</B>
<TD>Recursive mode, which means that subdirectories are also changed.
</TABLE>
<P><FONT SIZE="+1"><B><I>FOUR-DIGIT MODES</I></B></FONT></P>
<P>Occasionally there will be four-digit modes. In these cases, the extra digit is actually at the beginning of the mode and adds the following permissions:
</P>
<TABLE WIDTH="100%"><TR>
<TD WIDTH="20%"><B>4</B>
<TD>Sets user ID upon execution.
<TR>
<TD><B>2</B>
<TD>Sets group ID upon execution.
<TR>
<TD><B>1</B>
<TD>Sets the sticky bit.
</TABLE>
<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>
<DL>
<DD><B>chgrp</B>
<DD><B>chown</B>
</DL>
<P><FONT SIZE="+1"><B>chown......<TT>Change Owner</TT></B></FONT></P>
<P><B>chown</B> <I>option(s) newowner file(s)</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>chown</B> command changes the ownership of a file or directory. The new owner is either a username (one of which stored in <B>/etc/passwd</B>) or a user ID number. You must be the owner of this file or a privileged user (i.e., root user) to change the ownership.</P>
<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>
<TABLE WIDTH="100%">
<TR>
<TD WIDTH="20%"><B>-c</B>
<TD WIDTH="80%">Prints information about the changes made.
<TR>
<TD><B>-f</B>
<TD>Ignores information about files that can’t be changed.
<TR>
<TD><B>-v</B>
<TD>Verbose mode, where changes and failed changes are listed.
<TR>
<TD VALIGN="TOP"><B>-R</B>
<TD>Recursive mode, which means that subdirectories are also changed.
</TABLE>
<P><FONT SIZE="+1"><B><I>EXAMPLE</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ chown kevin report
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the ownership of <B>report</B> to the user <I>kevin</I>.</P>
<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>
<DL>
<DD><B>chmod</B>
<DD><B>chgrp</B>
</DL>
<P><FONT SIZE="+1"><B>chroot......<TT>Change Root Directory</TT></B></FONT></P>
<P><B>chroot</B> <I>path</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>chroot</B> directory changes the root directory of a Linux system to that specified in <I>path</I>. Only the root user may change the root directory.</P>
<P><FONT SIZE="+1"><B>cp......<TT>Copy Files</TT></B></FONT></P>
<P><B>cp</B> <I>option(s) file1 file2</I></P>
<P><B>cp</B> <I>option(s) file1 directory</I></P>
<P><B>cp</B> <I>option(s) directory1 directory2</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>cp</B> command copies files—the contents of one file into another file, the contents of a file into a new directory, or from one directory to another. The existing file isn’t changed.</P>
<P><FONT SIZE="+1"><B><I>OPTIONS</I></B></FONT></P>
<TABLE WIDTH="100%">
<TR>
<TD WIDTH="20%"><B>-a</B>
<TD WIDTH="80%">Retains archival attributes.
<TR>
<TD><B>-b</B>
<TD>Creates a backup instead of overwriting an existing file.
<TR>
<TD><B>-d</B>
<TD>Maintains symbolic links between files.
<TR>
<TD><B>-f</B>
<TD>Forces copying.
<TR>
<TD VALIGN="TOP"><B>-i</B>
<TD>Turns on interactive mode, where you are prompted before existing files are overwritten.
<TR>
<TD VALIGN="TOP"><B>-l</B>
<TD>Creates hard links between files copied to directories, instead of actually copying the files.
<TR>
<TD VALIGN="TOP"><B>-p</B>
<TD>Preserves existing permissions, including the ownership and time stamp.
<TR>
<TD><B>-r</B>
<TD>Copies entire directory and any subdirectories.
<TR>
<TD VALIGN="TOP"><B>-R</B>
<TD>Copies entire directory and any subdirectories.
<TR>
<TD VALIGN="TOP"><B>-s</B>
<TD>Creates symbolic links between files copied to directories, instead of actually copying the files.
<TR>
<TD VALIGN="TOP"><B>-S</B>
<TD>Sets a suffix to all new files; the default is ~ and stored in the SIMPLE_BACKUP_SUFFIX environment variable. Don’t change this variable, since other applications (notably <B>emacs</B>) also use it.
<TR>
<TD><B>-u</B>
<TD>Doesn’t copy to new files that are newer than the existing file.
<TR>
<TD VALIGN="TOP"><B>-v</B>
<TD>Turns on verbose mode, where all transactions are printed to screen.
<TR>
<TD VALIGN="TOP"><B>-V</B>
<TD>Uses the version-control numbering set with the VERSION_CONTROL environment variable.
<TR>
<TD><B>-x</B>
<TD>Ignores subdirectories on remote filesystems when copying.
</TABLE>
<P><FONT SIZE="+1"><B><I>EXAMPLES</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ cp pat.letter pat.old
</PRE>
<!-- END CODE SNIP //-->
<P>This copies the file <B>pat.letter</B> into a new file called <B>pat.old</B>.</P>
<!-- CODE SNIP //-->
<PRE>
$ cp kevin.letter /home/Kevin/kevin.letter
</PRE>
<!-- END CODE SNIP //-->
<P>This copies the file <B>kevin.letter</B>, contained in the current directory, to the file <B>kevin.letter</B>, stored in the <B>/home/Kevin</B> directory.</P>
<!-- CODE SNIP //-->
<PRE>
$ cp -r /home/Kevin /home/Kevin/letters
</PRE>
<!-- END CODE SNIP //-->
<P>This copies the entire contents of <B>/home/Kevin</B> into the directory <B>/home/Kevin/letters</B>.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="217-221.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="229-232.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?