rhl08.htm
来自「linux的初学电子书」· HTM 代码 · 共 2,355 行 · 第 1/5 页
HTM
2,355 行
<A NAME="E69E65"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Changing File Permissions</B></FONT></CENTER></H4>
<BR>
<P>To change file permissions, use the chmod (change [file] mode) command. The syntax is chmod <specification> file.
<BR>
<P>There are two ways to write the permission specification. One is by using the numeric coding system for permissions:
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~$ ls -l myfile
-rw-r—r— 1 fido users 114 Dec 7 14:31 myfile
darkstar:~$ chmod 345 myfile
darkstar:~$ ls -l myfile
—wxr—r-x 1 fido users 114 Dec 7 14:31 myfile
darkstar:~$ chmod 701 myfile
darkstar:~$ ls -l myfile
-rwx——x 1 root users 114 Dec 7 14:31 myfile</FONT></PRE>
<P>This method has the advantage of specifying the permissions in an absolute, rather than relative, fashion. Also, it's easier to tell someone "Change permissions on the file to seven-five-five" than to say "Change permissions on the file
to read-write-execute, read-execute, read-execute."
<BR>
<P>You can also use letter codes to change the existing permissions. To specify which of the permissions to change, type u (user), g (group), o (other), or a (all). This is followed by a + to add permissions or a - to remove them. This in turn is followed
by the permissions to be added or removed. For example, to add execute permissions for the group and others, you would type
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">darkstar:~$ chmod go+r myfile</FONT></PRE>
<P>Other ways of using the symbolic file permissions are described in the chmod man page.
<BR>
<BR>
<A NAME="E69E66"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Changing Directory Permissions</B></FONT></CENTER></H4>
<BR>
<P>You change directory permissions with chmod, exactly the same way as with files. Remember that if a directory doesn't have execute permissions, you can't cd to it.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Any user who has write permission in a directory can delete files in that directory, whether or not that user owns or has write privileges to those files.
<BR>Most directories, therefore, have permissions set to drwxr-xr-x. This ensures that only the directory's owner can create or delete files in that directory.
<BR>It is especially dangerous to give write permission to all users for directories!</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BR>
<A NAME="E68E58"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Miscellaneous File Commands</B></FONT></CENTER></H3>
<BR>
<P>There are many Linux commands to manipulate files, directories, and the entire file system. Many of these commands are used only by system administrators. You will touch on a few that are also used by ordinary users. These and other important system
administrator commands are further detailed in <A HREF="rhl37.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl37.htm">Chapter 37</A>, "System Administration Basics."
<BR>
<BR>
<A NAME="E69E67"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Fear of Compression The Zipless File</B></FONT></CENTER></H4>
<BR>
<P>Most Linux files are stored on the installation CD-ROM in compressed form. This allows more information to be stored.
<BR>
<P>When you installed Linux, the installation program uncompressed many of the files it transferred to your hard drive. However, if you look, you will be able to find compressed files!
<BR>
<P>Any file ending in .gz—for example, squashed.gz—is a compressed file. To uncompress this particular type of file, type gunzip <file>. For this example, you would type gunzip squashed.gz. The gunzip program creates an uncompressed file
and removes the .gz extension. Therefore, you would wind up with a normal file called squashed.
<BR>
<P>To compress a file, use the gzip command. Typing gzip squashed would compress squashed and rename it squashed.gz.
<BR>
<P>Another type of compressed file you might see ends with the extension .zip. Use unzip to uncompress these files. To create files of this type, use zip.
<BR>
<BR>
<A NAME="E69E68"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>How to tar Without Feathering</B></FONT></CENTER></H4>
<BR>
<P>In almost any location with several Linux or UNIX systems, sooner or later you will hear someone say, "Put that in a tar file and send it over."
<BR>
<P>They are referring to the output created by the tar program. Although tar stands for tape archive, it can copy files to floppy disk or to any filename you specify in the Linux file system. The tar command is used because it can archive files and
directories into a single file and then recreate the files and even the directory structures later. It's also the easiest way to place Linux files on a floppy disk.
<BR>
<P>To create a tar file, you typically type tar cvf <destination> <files/directories>, where files/directories specifies the files and directories to be archived, and destination is where you want the tar file to be created. If you want the
destination to be a floppy disk, you usually type /dev/fd0 as the destination. This specifies your primary floppy drive (A: in MS-DOS). You can use a floppy disk that's been formatted under MS-DOS.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>When tar archives to a floppy disk, all the data already on the disk is destroyed. You have to reformat it to use it with MS-DOS again.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>To extract a tar file, you typically type tar xvf <tar file>. For instance, to pull files from a floppy disk, you would type tar xvf /dev/fd0.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Unlike gzip, tar doesn't remove, delete, or rename files it puts into the archive. However, when tar extracts archived files, it overwrites existing files with files of the same name from the archive.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BR>
<A NAME="E68E59"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Important Directories in the Linux File System</B></FONT></CENTER></H3>
<BR>
<P>Most of the directories that hold Linux system files are "standard." Other UNIX systems will have identical directories with similar contents. This section summarizes some of the more important directories on your Linux system.
<BR>
<BR>
<A NAME="E69E69"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/</B></FONT></CENTER></H4>
<BR>
<P>This is the root directory. It holds the actual Linux program, as well as subdirectories. Do not clutter this directory with your files!
<BR>
<BR>
<A NAME="E69E70"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/home</B></FONT></CENTER></H4>
<BR>
<P>This directory holds users' home directories. In other UNIX systems, this can be the /usr or /u directory.
<BR>
<BR>
<A NAME="E69E71"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/bin</B></FONT></CENTER></H4>
<BR>
<P>This directory holds many of the basic Linux programs. bin stands for binaries, files that are executable and that hold text only computers could understand.
<BR>
<BR>
<A NAME="E69E72"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/usr</B></FONT></CENTER></H4>
<BR>
<P>This directory holds many other user-oriented directories. Some of the most important are described in the following sections. Other directories found in /usr include
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
docs
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Various documents, including useful Linux information</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
man
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
The man pages accessed by typing man <command></FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
games
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
The fun stuff!</FONT>
</TABLE><BR>
<A NAME="E69E73"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/usr/bin</B></FONT></CENTER></H4>
<BR>
<P>This directory holds user-oriented Linux programs.
<BR>
<BR>
<A NAME="E69E74"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/var/spool</B></FONT></CENTER></H4>
<BR>
<P>This directory has several subdirectories. mail holds mail files, spool holds files to be printed, and uucp holds files copied between Linux machines.
<BR>
<BR>
<A NAME="E69E75"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/dev</B></FONT></CENTER></H4>
<BR>
<P>Linux treats everything as a file! The /dev directory holds devices. These are special files that serve as gateways to physical computer components. For instance, if you copy to /dev/fd0, you're actually sending data to the system's floppy disk. Your
terminal is one of the /dev/tty files. Partitions on the hard drive are of the form /dev/hd0. Even the system's memory is a device!
<BR>
<P>A famous device is /dev/null. This is sometimes called the bit bucket. All information sent to /dev/null vanishes—it's thrown into the trash.
<BR>
<BR>
<A NAME="E69E76"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/usr/sbin</B></FONT></CENTER></H4>
<BR>
<P>This directory holds system administration files. If you do an ls -l, you see that you must be the owner, root, to run these commands.
<BR>
<BR>
<A NAME="E69E77"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/sbin</B></FONT></CENTER></H4>
<BR>
<P>This directory holds system files that are usually run automatically by the Linux system.
<BR>
<BR>
<A NAME="E69E78"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>/etc</B></FONT></CENTER></H4>
<BR>
<P>This directory and its subdirectories hold many of the Linux configuration files. These files are usually text, and they can be edited to change the system's configuration (if you know what you're doing!).
<BR>
<BR>
<A NAME="E68E60"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>
<BR>
<P>You should now feel more comfortable working in Linux. Understanding and being able to navigate the Linux file system is very important, since Linux really does consist simply of some files organized in a fairly standard way.
<BR>
<P>You still might find yourself stumped by certain file or directory problems. Remember that the online man pages can assist you. Linux gives you a lot of flexibility in creating files, specifying absolute or relative names, and setting permissions. Don't
be afraid to experiment (as an ordinary user, in your home directory). There are too many different ways to perform tasks to list or exhaustively describe here. Don't cling to rigid recipes written on a piece of paper. You learn by trying!
<BR>
<P>You should go on to Chapters 9, "Introduction to the GNU Project Utilities," through 12, "Using tcsh," especially if you want to create programs or macros from system command files or learn more about the built-in user interface
features in Linux shells. <A HREF="rhl16.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl16.htm">Chapter 16</A> has some very useful information about editing text files.
<BR>
<P>Once you are familiar with shells and have had some practice manipulating files and directories, you can move on to the advanced topics in Part III, "Editing, Typesetting, and More," through Part VIII, "Advanced Programming Topics,"
of this book.
<P ALIGN=LEFT>
<A HREF="rhl07.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl07.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>
<A HREF="#I0" TARGET="_self"><IMG SRC="purtop.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtop.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Page Top"></A>
<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>
<A HREF="rhl09.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl09.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>
</BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?