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

📄 008-011.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux in Plain English:Linux Structures and Commands</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=1//-->

<!--PAGES=008-011//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="005-008.html">Previous</A></TD>

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

<TD><A HREF="012-015.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H3><A NAME="Heading3"></A><FONT COLOR="#000077">Files</FONT></H3>

<P>The <B>ls</B> command is used to list the files in the current or a given directory. In some ways, it&#146;s an oddity in the Linux world, as it&#146;s not used directly on a file, which is the method Linux uses for organizing information. As you browse through the rest of this book, you&#146;ll see that the vast majority of commands are used in conjunction with files.</P>

<P>This isn&#146;t surprising when you stop to consider that everything in the Linux operating system is a file. You saw the <B>ls</B> command used to list files in a directory, and the reason that command is so handy is that everything in Linux is a file. Commands are actually files that are invoked as programs. Devices attached to your PC are actually represented in the Linux operating system by files (usually beginning with <B>dev</B>). When you print a file, you&#146;re actually sending a file to a file representing the printer.</P>

<P>At a basic level, a file is nothing more than an organized area of a storage device (like a hard disk or a floppy drive), made up of <I>bits</I>. Bits are nothing more than digital players in an electronic format, representing either 0 or 1. The Linux operating system takes these bits and formats them in a way that&#146;s recognizable to both you and the operating system. Without this organization, the contents of a hard drive would just be random zeroes and ones. This organizational scheme is called the <I>filesystem</I>.</P>

<P>That&#146;s why the main function of the Linux operating system is to keep track of and manipulate these files. The importance of the <B>ls</B> command can&#146;t be overstated, since it lets you know which files are in a portion of the filesystem at a given time. That&#146;s why the most frequently used commands in Linux relate to manipulating files on basic levels, such as <B>elvis</B> for editing files, <B>del</B> for deleting files, and <B>mv</B> for moving files.</P>

<P>There are four types of files:</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;Device files

<DD><B>&#149;</B>&nbsp;&nbsp;Directories

<DD><B>&#149;</B>&nbsp;&nbsp;Links

<DD><B>&#149;</B>&nbsp;&nbsp;Ordinary files

</DL>

<P>Each is explained, in order of its importance in the Linux operating system:

</P>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;<I>Ordinary files</I> are the rank and file of Linux files, usually containing data that&#146;s acted upon by other programs and the operating system itself. An ordinary file can be an ASCII text file, a data file for a program (such as a formatted file for a page-layout program or a database file for a database manager), a command file (which contains further instructions for a program but is stored in ASCII text, such as a Perl or Tcl script), or an executable program file.

<DD><B>&#149;</B>&nbsp;&nbsp;<I>Directories</I> are files that represent information about other files. Files in the Linux operating system are stored hierarchically, with files stored within collections of other files. Directories will be explained later in this chapter.

<DD><B>&#149;</B>&nbsp;&nbsp;<I>Device files</I> represent the devices attached to your PC. These devices are stored in the <B>/dev</B> directory; for instance, a tape drive is represented by <B>/dev/st0</B>.

<DD><B>&#149;</B>&nbsp;&nbsp;<I>Links</I> are multiple names in the filesystem that represent the same file. Links aren&#146;t that big a deal with Linux, unless you&#146;re working on a network. Links are a remnant of the old UNIX days, when hard-disk space was so tight users would share one file, but because of the needs of the network, different names were given to the file.

</DL>

<H3><A NAME="Heading4"></A><FONT COLOR="#000077">Directories</FONT></H3>

<P>As you saw earlier, directories are merely files that are used to store other files. Directories are an absolute must for an operating system like Linux. In Linux, every command is a file, every device is a file, and every program is at least one file (but usually many more). Add up all of these files, and you&#146;ll end up with a mess of a filesystem, with thousands of individual files. To make matters worse, Linux is designed to be on a network, which means that every user has access to thousands of other files across the network and possibly on a file server. There would be no workable way to keep track of these files unless they could be stored in some sort of hierarchy. That&#146;s where directories come in.

</P>

<P>The directory hierarchy in Linux, which you can visualize as a pyramid, is actually pretty simple. There&#146;s a <I>root directory</I>, which is at the top of the pyramid, and it&#146;s represented by a slash (/). Every directory is a <I>subdirectory</I> of the root directory. In addition, there are subdirectories within subdirectories.</P>

<P>As a user, you are &#147;in&#148; a directory at all times. This is called the <I>current directory</I>. Your command prompt usually lists the name of the current directory (beginning with a slash, which indicates that the directory hierarchy begins with a root directory).</P>

<P>A standard Linux installation, such as Slackware Linux, has a fairly predictable set of directories. When your current directory is the root directory, Linux features a set of subdirectories like those shown in Figure 1.5.</P>

<P><A NAME="Fig5"></A><A HREF="javascript:displayWindow('images/01-05.jpg',589,367 )"><IMG SRC="images/01-05t.jpg"></A>

<BR><A HREF="javascript:displayWindow('images/01-05.jpg',589,367)"><FONT COLOR="#000077"><B>Figure 1.5</B></FONT></A>&nbsp;&nbsp;The root directory in a typical Slackware Linux installation.</P>

<P>Some of these directories are found in almost all Linux and UNIX installations, such as <B>etc</B>, <B>sbin</B>, <B>usr</B>, and <B>var</B>. Other directories are unique to Linux, such as <B>boot</B>, <B>cdrom</B>, <B>mnt</B>, <B>proc</B>, and <B>shlib</B>. Still others are devoted to users, such as <B>root</B> and <B>users</B>. If you installed Linux on your own, you probably have at least one <I>home directory</I> (<B>root</B>, used when you&#146;re logged in as the root user) and probably two (like a named directory under <B>users</B>).</P>

<P>Linux features a number of commands for creating your own directories, which are covered throughout the course of this book.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="005-008.html">Previous</A></TD>

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

<TD><A HREF="012-015.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 + -