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

📄 153-156.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 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=153-156//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="152-153.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="156-158.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H4 ALIGN="LEFT"><A NAME="Heading9"></A><FONT COLOR="#000077">The Home Directory</FONT></H4>

<P>Linux provides each user with his or her own directory called the <I>home</I> directory. Within this home directory, users can store their own files and create subdirectories. Users generally have complete control over what&#146;s found in their home directories. Because there are usually no Linux system files or files belonging to other users in your home directory, you can create, name, move, and delete files and directories as you see fit.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>Warning:&nbsp;&nbsp;</B><BR>Your home directory does not provide privacy! Normally, any user can go into another&#146;s home directory and read (and copy!) the files stored there (although he can&#146;t delete or change the files). When Linux creates your home directory, it in effect provides you with an open office cubicle whose desk and filing cabinet drawers are unlocked.<P>You <I>must</I> lock up everything you want to keep private. (This topic is covered in Chapter 9, &#147;File and Directory Permissions.&#148;) It is generally considered rude or nosy to poke around in someone else&#146;s home directory, just as it&#146;s rude or nosy to poke around in someone&#146;s office while they&#146;re away from their desk, but the world is full of nosy and rude people so you must take precautions!</P>

<P>Note that anyone logged in as <TT>root</TT> can read and manipulate <I>all</I> the files on the system, including files that users have locked up. If you can&#146;t trust the system administrator (who usually has the <TT>root</TT> password), don&#146;t use the system!<HR></FONT>

</BLOCKQUOTE>

</P>

<P>The location of a user&#146;s home directory is specified by Linux and can&#146;t be changed by the user. This is both to keep things tidy and to preserve system security. The location of your home directory depends on which version of Linux you&#146;re using and how the system installed itself, but usually it is something like <TT><B>/home/tim</B></TT> or <TT><B>/usr/tim</B></TT>, where &#147;tim&#148; is the login name. When you log into the system, you are placed in your home directory by default.</P>

<H3><A NAME="Heading10"></A><FONT COLOR="#000077">Navigating the Linux File System</FONT></H3>

<P>Fortunately, navigating the Linux file system is simple. There are only two commands to be learned, and one of them has absolutely no options or parameters!

</P>

<H4 ALIGN="LEFT"><A NAME="Heading11"></A><FONT COLOR="#000077">The pwd Command: Where Am I?</FONT></H4>

<P>Type <TT><B>pwd</B></TT> at the Linux command prompt. You see</P>

<!-- CODE SNIP //-->

<PRE>

darkstar:~&#36; <B>pwd</B>

/home/fido

darkstar:~&#36;

</PRE>

<!-- END CODE SNIP //-->

<P>This tells you that you&#146;re currently in the directory <TT><B>/home/fido</B></TT>. (If you are logged in under a different username, you will see that name in place of <TT><B>fido</B></TT>.) This is your home directory. As we mentioned earlier, when you log in, Linux always places you in your home directory.</P>

<P>The letters &#147;pwd&#148; stand for &#147;print working directory.&#148; Again, a command&#146;s name or function has been cut down to a few easy-to-type characters. (You will often see the term <I>current directory</I> used in place of <I>working directory</I>.)</P>

<P>You might be wondering what &#147;working directory&#148; or &#147;being in a directory&#148; really means. It simply means that Linux commands, by default, perform their actions in your working directory. For instance, when you run <TT><B>ls</B></TT>, you are shown only the files in your working directory. If you want to create or remove files, they will be created or removed in your working directory. You can change your working directory with the <TT><B>cd</B></TT> command, as you&#146;ll see in a moment.</P>

<H4 ALIGN="LEFT"><A NAME="Heading12"></A><FONT COLOR="#000077">Absolute and Relative Filenames</FONT></H4>

<P>If you specify only the name of a file, Linux looks for that file in your working directory. For example, <TT><B>more myfile</B></TT> lets you read the contents of the file <TT><B>myfile</B></TT>. But <TT><B>myfile</B></TT> must be in your current working directory or the <TT><B>more</B></TT> command can&#146;t find it.</P>

<P>Sometimes you want to specify a file that isn&#146;t in your current directory. In this case, you must then specify the name of the directory the file is in, as well as the name of the file itself. If, for example, your current directory has a subdirectory called <TT><B>novel</B></TT> which contains a file called <TT><B>chapter_1</B></TT>, you could type <TT><B>more novel/chapter_1</B></TT> which tells <TT><B>more</B></TT> that it should look in the subdirectory <TT><B>novel</B></TT> for the file <TT><B>chapter_1</B></TT>. This is called a <I>relative filename</I>. You are specifying the location of <TT><B>chapter_1</B></TT> <I>relative</I> to where you are now, in the subdirectory <TT><B>novel</B></TT>, which in turn is found in your current directory. If you have changed your working directory, the relative filename will no longer work.</P>

<P>Two special directory specifications are &#147;<B>.</B>&#148; and &#147;<B>..</B>&#148;. The single period &#147;<B>.</B>&#148; always stands for the directory you are currently in, and &#147;<B>..</B>&#148; stands for the parent directory of your current directory. (You will see how &#147;<B>.</B>&#148; and &#147;<B>..</B>&#148; are used later in this chapter.) Any filename that includes &#147;<B>.</B>&#148; or &#147;<B>..</B>&#148; is, by definition, a relative filename.</P>

<P>A filename that is valid from any location is called an <I>absolute filename</I>. Absolute filenames always begin with <B>/</B>, signifying the root directory. So if you specify a filename as <TT><B>/home/fido/novel/chapter_1</B></TT>, there is no doubt as to where the file is located. Every file on your system has a unique absolute filename. You can use the absolute filename to figure out what Linux is doing when you specify a filename. In the example just mentioned, Linux will start in the root directory <B>/</B> and look for a subdirectory called <TT><B>home</B></TT>. Linux makes <TT><B>/home</B></TT> the current directory temporarily and looks for a directory called <TT><B>fido</B></TT>, then makes that current, looks for <TT><B>novel</B></TT> and makes that current. Once in novel, Linux looks for a file or directory called chapter_1. You can read the absolute filename like a road map, telling you how to navigate the Linux file system.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="152-153.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="156-158.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 + -