📄 152-153.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Unleashed, Third Edition:Using the File System</TITLE>
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0672313723//-->
<!--TITLE=Linux Unleashed, Third Edition//-->
<!--AUTHOR=Tim Parker//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Sams//-->
<!--CHAPTER=8//-->
<!--PAGES=152-153//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="149-152.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="153-156.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading5"></A><FONT COLOR="#000077">Directories: An Overview</FONT></H3>
<P>Linux, like many other computer systems, organizes files into <I>directories</I>. You can think of directories as file folders and their contents as the files. However, there is one absolutely crucial difference between the Linux file system and an office filing system. In the office, file folders usually don’t contain other file folders. In Linux, file folders <I>can</I> contain other file folders. In fact, there is no Linux “filing cabinet”—just a huge file folder that holds some files and other folders. These folders contain files and possibly other folders in turn, and so on.</P>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Parent Directories and Subdirectories</FONT></H4>
<P>Imagine a scenario in which you have a directory, A, that contains another directory, B. Directory B is then a <I>subdirectory</I> of directory A, and directory A is the <I>parent directory</I> of directory B. You will see these terms often, both in this book and elsewhere.</P>
<P>With Linux, there is no real limit to the number of directories and subdirectories you have on your system. The same applies for the number of files. As long as there is space on the hard drive, Linux will be able to save files and directories. A directory can have an unlimited number of subdirectories, and they themselves can have an unlimited number of subdirectories, and so on. Each directory and subdirectory can have an unlimited number of files. The key to understanding the way Linux organizes files and directories is recognizing that there is only one top-level directory, from which all others are subdirectories.</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">The Root Directory</FONT></H4>
<P>In Linux, the directory that holds all the other directories is called the <I>root directory</I>. This is the ultimate parent directory; every other directory is some level of subdirectory. The root directory has a special symbol, /, which is used to show it is the top level. You’ll see how all other subdirectories branch off from the root directory in the next few sections.</P>
<P>From the root directory, the whole structure of directory upon directory springs and grows like some electronic elm tree. This is called a <I>tree structure</I> because, from the single <I>root</I> directory, directories and subdirectories branch off like tree limbs. You’ll also hear this called a hierarchical directory structure because there is a hierarchy of levels of directories, with the highest level as the root directory.</P>
<P>Just a quick word about file systems. You’ll see the words file system used throughout this book. That’s because UNIX has always referred to directory structures as file systems. There’s quite a bit of history behind it, but all the directories on your Linux system are your system’s file system. That’s where Linux stores the files.</P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">How Directories Are Named</FONT></H4>
<P>Directories are named just like files, and they can contain upper- and lowercase letters, numbers, and characters such as <B>-</B>, <B>.</B>, and <B>_</B>. Essentially, to Linux a directory name is a file because it makes no distinction between the two. You can name directories the same, as long as they are not in the same parent directory (to prevent having two directories called “data” under the same parent directory), but you can have any number of directories called “data” in your file system as long as they don’t share parents.</P>
<P>The slash (<B>/</B>) character is used to show files or directories within other directories. For instance, <TT><B>usr/bin</B></TT> means that <TT><B>bin</B></TT> is found in the <TT><B>usr</B></TT> directory. Note that you can’t tell from this example whether <TT><B>bin</B></TT> is a file or a directory, although you know that <TT><B>usr</B></TT> must be a directory because it holds another item—namely, the directory <TT><B>bin</B></TT>. When you see <TT><B>usr/bin/grep</B></TT>, you know that both <TT><B>usr</B></TT> and <TT><B>bin</B></TT> must be directories, but again, you can’t be sure about</P>
<TT><B>grep</B></TT>. The <TT><B>ls</B></TT> program often shows directories followed by a backslash (sometimes this requires the -F option)—for example, to show that fido is a directory, <TT><B>ls</B></TT> shows it as <TT><B>fido/</B></TT>. This notation implies that you could have, for instance, <TT><B>fido/file</B></TT>; therefore, <TT><B>fido</B></TT> must be a directory.
<P>As mentioned earlier, the root directory is shown simply by the symbol / rather than mentioned by name. It’s very easy to tell when / is used to separate directories and when it’s used to signify the root directory. If / has no name <I>before</I> it, it stands for the root directory. For example, <TT><B>/usr</B></TT> means that the <TT><B>usr</B></TT> subdirectory is found in the root directory, and <TT><B>/usr/bin</B></TT> means that <TT><B>bin</B></TT> is found in the <TT><B>usr</B></TT> directory and that <TT><B>usr</B></TT> is a subdirectory of the root directory. Remember, by definition the root directory cannot be a subdirectory.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="149-152.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="153-156.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 + -