📄 217-221.html
字号:
<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=217-221//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="209-216.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="221-228.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading3"></A><FONT COLOR="#000077">File-Management Commands</FONT></H3>
<P>These commands are used to manage your files and directories—move them, copy them, delete them, compress them, and more.
</P>
<P><FONT SIZE="+1"><B>basename......<TT>Basename Listing</TT></B></FONT></P>
<IMG SRC="images/05-89i.jpg"><P><B>basename</B> <I>filename.suffix</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>basename</B> command (if specified on the command line) strips leading directories and the suffix.</P>
<P><FONT SIZE="+1"><B><I>EXAMPLE</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ basename changes.txt
changes
</PRE>
<!-- END CODE SNIP //-->
<P><FONT SIZE="+1"><B>cd Change......<TT>Directory</TT></B></FONT></P>
<P><B>cd</B> <I>directory</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>cd</B> command changes the current directory. Although this is actually a shell command, it’s normally treated as a standard Linux command.</P>
<P><FONT SIZE="+1"><B><I>EXAMPLES</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ cd
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the current directory to your home directory.
</P>
<!-- CODE SNIP //-->
<PRE>
$ cd /usr/kevin
</PRE>
<!-- END CODE SNIP //-->
<P>This changes your current directory to the directory named <B>/usr/kevin</B>.</P>
<!-- CODE SNIP //-->
<PRE>
$ cd kevin
</PRE>
<!-- END CODE SNIP //-->
<P>This changes your directory to the subdirectory named <B>kevin</B>.</P>
<!-- CODE SNIP //-->
<PRE>
$ cd ~
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the current directory to your home directory.
</P>
<!-- CODE SNIP //-->
<PRE>
$ cd /
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the current directory to the root directory.
</P>
<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>
<TABLE WIDTH="100%">
<TR>
<TD WIDTH="20%"><B>pwd</B>
<TD WIDTH="80%">Prints the name of the current directory.
</TABLE>
<P><FONT SIZE="+1"><B>chgrp......<TT>Change Group</TT></B></FONT></P>
<P><B>chgrp</B> <I>option(s) newgroup file(s)/directory</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>chgrp</B> command changes the group assignments associated with a file or directory. Group IDs or group names can be assigned to a file or a directory (the information is stored in <B>/etc/groups</B>). You must own a file or be the root user in order to change the groups.</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>Returns all information about the changes in verbose form.
<TR>
<TD VALIGN="TOP"><B>-R</B>
<TD>Recursive mode, which means that subdirectories are also changed.
</TABLE>
<P><FONT SIZE="+1"><B><I>EXAMPLES</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ chgrp management kevin.memo
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the group for <B>kevin.memo</B> to the <B>restricted</B> group.</P>
<!-- CODE SNIP //-->
<PRE>
$ chgrp -R management /home/kevin/memos
</PRE>
<!-- END CODE SNIP //-->
<P>This changes the group for the directory <B>/home/kevin/memos</B>, its contents, and all subdirectories within to the <B>restricted</B> group.</P>
<P><FONT SIZE="+1"><B><I>RELATED COMMANDS</I></B></FONT></P>
<DL>
<DD><B>chown</B>
<DD><B>chmod</B>
</DL>
<P><FONT SIZE="+1"><B>chmod......<TT>Change Mode</TT></B></FONT></P>
<P><B>chmod</B> <I>option(s) mode file(s)</I></P>
<P><FONT SIZE="+1"><B><I>PURPOSE</I></B></FONT></P>
<P>The <B>chmod</B> command changes the permissions associated with a file or directory. Permissions are set for the owner of a file, a group owner of the file, and the world at large. Permissions are stored in one of two ways: numeric or symbolic form. The symbolic form is used to set values relative to the current permissions, while the numeric method is used to set absolute permissions. These values are in modes, which can be an octal number (when using the numeric form) or a symbol (when using the symbolic method). You can combine modes if you separate them with a comma.</P>
<P>You must own a file or be the root user in order to change the permissions.</P>
<P>The current permissions for a file can be displayed with the <B>ls</B> command, which is covered elsewhere in this section. The <B>ls</B> command lists the permissions in the following manner:</P>
<!-- CODE SNIP //-->
<PRE>
rwxr--w--
</PRE>
<!-- END CODE SNIP //-->
<P>Permissions are set in trios: owner, group, and world. Any of the three can read (<B>r</B>), write (<B>w</B>), and execute (<B>x</B>). If permission is denied to one of the three, the letter is replaced with a hyphen (<B>-</B>). The root user has full permissions for every file.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Permissions are one of the more important things to watch when using the Linux operating system. Many beginners get tripped up because they want to run or access a file, only to find out that they don’t have permission to do so.<HR></FONT>
</BLOCKQUOTE>
<P><FONT SIZE="+1"><B><I>EXAMPLES USING SYMBOLIC FORM</I></B></FONT></P>
<!-- CODE SNIP //-->
<PRE>
$ chmod g+x pat.memo
</PRE>
<!-- END CODE SNIP //-->
<P>This command line adds the permission to execute a file (<B>x</B>) to the group (<B>g</B>). In symbolic form, permissions are added or subtracted to existing permissions.</P>
<!-- CODE SNIP //-->
<PRE>
$ chmod go-w pat.memo
</PRE>
<!-- END CODE SNIP //-->
<P>This command line removes the write permissions from the group and the world.
</P>
<!-- CODE SNIP //-->
<PRE>
$ chmod g+x,go-w pat.memo
</PRE>
<!-- END CODE SNIP //-->
<P>This command line adds the permission to execute a file to the group, while removing the write permissions from the group and the world.
</P>
<P><FONT SIZE="+1"><B><I>SYMBOLS</I></B></FONT></P>
<P>The following symbols are used to set the mode:
</P>
<TABLE WIDTH="100%"><TR>
<TD WIDTH="20%"><B>u</B>
<TD WIDTH="80%">User (the current owner of the file).
<TR>
<TD><B>g</B>
<TD>Group.
<TR>
<TD><B>o</B>
<TD>Other (world).
<TR>
<TD><B>all</B>
<TD>All (the default).
<TR>
<TD><B>+</B>
<TD>Adds a permission to the current permissions.
<TR>
<TD><B>-</B>
<TD>Deletes a permission from the current permissions.
<TR>
<TD VALIGN="TOP"><B>=</B>
<TD>Assigns a permission while deleting the other permissions from unspecified fields.
<TR>
<TD><B>r</B>
<TD>Read.
<TR>
<TD><B>w</B>
<TD>Write.
<TR>
<TD><B>e</B>
<TD>Execute.
<TR>
<TD><B>s</B>
<TD>Sets user ID
<TR>
<TD VALIGN="TOP"><B>t</B>
<TD>Sets sticky bit, which is used for additional security both on a Linux system and the Internet.
<TR>
<TD><B>l</B>
<TD>Sets mandatory lock.
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="209-216.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="221-228.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -