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

📄 ch08.htm

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTM
📖 第 1 页 / 共 5 页
字号:


<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>

 -->






 











 

















<H1></H1>







<UL>



	<LI><A HREF="#Heading1">- 8 -</A>



	<UL>



		<LI><A HREF="#Heading2">File System</A>



		<UL>



			<LI><A HREF="#Heading3">Files: An Overview</A>



			<UL>



				<LI><A HREF="#Heading4">Common Types of Files</A>



				<LI><A HREF="#Heading5">Filenames</A>



			</UL>



			<LI><A HREF="#Heading6">Directories: An Overview</A>



			<UL>



				<LI><A HREF="#Heading7">Parent Directories and Subdirectories</A>



				<LI><A HREF="#Heading8">The Root Directory</A>



				<LI><A HREF="#Heading9">How Directories Are Named</A>



				<LI><A HREF="#Heading10">The Home Directory</A>



			</UL>



			<LI><A HREF="#Heading11">WARNING</A>



			<LI><A HREF="#Heading12">Navigating the Linux File System</A>



			<UL>



				<LI><A HREF="#Heading13">The pwd Command: Where Am I?</A>



				<LI><A HREF="#Heading14">Absolute and Relative Filenames</A>



				<LI><A HREF="#Heading15">Going Places: The cd Command</A>



				<LI><A HREF="#Heading16">Theres No Place Like Home</A>



			</UL>



			<LI><A HREF="#Heading17">TIP</A>



			<LI><A HREF="#Heading18">Creating and Deleting Files</A>



			<LI><A HREF="#Heading19">WARNING</A>



			<UL>



				<LI><A HREF="#Heading20">cat: That Useful Feline</A>



			</UL>



			<LI><A HREF="#Heading21">NOTE</A>



			<UL>



				<LI><A HREF="#Heading22">Creating Directories</A>



			</UL>



			<LI><A HREF="#Heading23">TIP</A>



			<UL>



				<LI><A HREF="#Heading24">Moving and Copying Files</A>



			</UL>



			<LI><A HREF="#Heading25">WARNING</A>



			<UL>



				<LI><A HREF="#Heading26">Moving and Copying with Wildcards</A>



			</UL>



			<LI><A HREF="#Heading27">NOTE</A>



			<UL>



				<LI><A HREF="#Heading28">Moving Directories</A>



			</UL>



			<LI><A HREF="#Heading29">NOTE</A>



			<LI><A HREF="#Heading30">Removing Files and Directories</A>



			<LI><A HREF="#Heading31">WARNING</A>



			<UL>



				<LI><A HREF="#Heading32">Removing Directories</A>



			</UL>



			<LI><A HREF="#Heading33">TIP</A>



			<LI><A HREF="#Heading34">WARNING</A>



			<LI><A HREF="#Heading35">File Permissions and Ownership</A>



			<UL>



				<LI><A HREF="#Heading36">File and Directory Ownership</A>



				<LI><A HREF="#Heading37">File Permissions</A>



			</UL>



			<LI><A HREF="#Heading38">TIP</A>



			<LI><A HREF="#Heading39">NOTE</A>



			<LI><A HREF="#Heading40">WARNING</A>



			<UL>



				<LI><A HREF="#Heading41">Changing File Permissions</A>



				<LI><A HREF="#Heading42">Changing Directory Permissions</A>



			</UL>



			<LI><A HREF="#Heading43">WARNING</A>



			<LI><A HREF="#Heading44">Miscellaneous File Commands</A>



			<UL>



				<LI><A HREF="#Heading45">Fear of Compression: The Zipless File</A>



				<LI><A HREF="#Heading46">How to tar Without Feathering</A>



			</UL>



			<LI><A HREF="#Heading47">WARNING</A>



			<LI><A HREF="#Heading48">NOTE</A>



			<LI><A HREF="#Heading49">Important Directories in the Linux File System</A>



			<UL>



				<LI><A HREF="#Heading50">/</A>



				<LI><A HREF="#Heading51">/home</A>



				<LI><A HREF="#Heading52">/bin</A>



				<LI><A HREF="#Heading53">/usr</A>



				<LI><A HREF="#Heading54">/usr/bin</A>



				<LI><A HREF="#Heading55">/usr/spool</A>



				<LI><A HREF="#Heading56">/dev</A>



				<LI><A HREF="#Heading57">/usr/sbin</A>



				<LI><A HREF="#Heading58">/sbin</A>



				<LI><A HREF="#Heading59">/etc</A>



			</UL>



			<LI><A HREF="#Heading60">Summary</A>



		</UL>



	</UL>



</UL>







<P>



<HR SIZE="4">







<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 8 -</FONT></H2>



<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">File System</FONT></H2>



<P><I>by Ed Treijs</I></P>







<P>IN THIS CHAPTER</P>







<UL>



	<LI>Files: An Overview 116



	<P>



	<LI>Directories: An Overview 117



	<P>



	<LI>Navigating the Linux File System 119



	<P>



	<LI>Creating and Deleting Files 122



	<P>



	<LI>Removing Files and Directories 127



	<P>



	<LI>File Permissions and Ownership 130



	<P>



	<LI>Miscellaneous File Commands 134



	<P>



	<LI>Important Directories in the Linux File System 135



</UL>







<P><BR>



In this chapter, you learn about







<UL>



	<LI>Files: what they are, types of files, filenames



	<P>



	<LI>Directories: what they are, parent directories and subdirectories, directory



	names, your home directory



	<P>



	<LI>Absolute and relative file and directory names



	<P>



	<LI>Moving between directories using the <TT>cd</TT> command



	<P>



	<LI>Using the <TT>cat</TT> command to create a new file



	<P>



	<LI>Creating directories



	<P>



	<LI>Moving and copying files



	<P>



	<LI>Removing files and directories



	<P>



	<LI>File and directory ownership, using <TT>chown</TT> and <TT>chgrp</TT> to change



	ownership



	<P>



	<LI>File and directory permissions, using <TT>chmod</TT> to change permissions



	<P>



	<LI>Using the <TT>gunzip</TT> command to uncompress <TT>.gz</TT> files compressed



	by <TT>gzip</TT>



	<P>



	<LI>The <TT>tar</TT> command



	<P>



	<LI>The standard Linux directories and directory structure



</UL>







<P>To understand how Linux works, and to use the system beyond a superficial level,



you must be familiar with the Linux notion of files and the file system into which



they are organized.



<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">Files: An Overview</FONT></H3>



<P>The most basic concept of a file, and one you may already be familiar with from



other computer systems, defines a file as a distinct chunk of information that is



found on your hard drive. Distinct means that there can be many different files,



each with its own particular contents. To keep files from getting confused with each



other, every file must have a unique identity. In Linux, you identify each file by



its name and location. In each location or directory, there can be only one file



by a particular name. So, for instance, if you create a file called <TT>novel</TT>,



and you get a second great idea, you will either have to call it something different,



such as <TT>novel2</TT>, or put it in a different place, to keep from overwriting



the contents already in your original <TT>novel</TT>.



<H4 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">Common Types of Files</FONT></H4>



<P>Files can contain various types of information. The following three types will



become the most familiar to you:







<UL>



	<LI>User data: Information that you create and update. The very simplest user data



	is plain text or numbers. You learn to create these simple files later in this chapter.



	More complicated user data files might have to be interpreted by another program



	to make sense. For instance, a spreadsheet file looks like gibberish if you look



	at it directly. To work with a spreadsheet, you have to start up the spreadsheet



	program and read in the spreadsheet file.



	<P>



	<LI>System data: Information, often in plain text form, that is read and used by



	the Linux system--to keep track of which users are allowed on the system, for instance.



	As a system administrator, you are responsible for changing system data files. For



	instance, when you create a new user, you modify the file <TT>/etc/passwd</TT>, which



	contains the user information. Ordinary users of the system are usually not concerned



	with system data files, except for their private startup files.



	<P>



	<LI>Executable files: These files contain instructions that your computer can perform.



	This set of instructions is often called a program. When you tell the computer to



	perform them, you're telling it to execute the instructions given to it. To human



	eyes, executable files contain meaningless gibberish--obviously your computer doesn't



	think the way you do! Creating or modifying executable files takes special tools.



	You learn how to use these programming tools in Part V, &quot;Linux for Programmers.&quot;



</UL>







<H4 ALIGN="CENTER"><A NAME="Heading5<FONT COLOR="#000077">Filenames</FONT></H4>



<P>Linux allows filenames to be up to 256 characters long. These characters can be



lower- and uppercase letters, numbers, and other characters, usually the dash (-),



the underscore (_), and the dot (.).</P>



<P>They can't include reserved metacharacters such as the asterisk, question mark,



backslash, and space, because these all have meaning to the shell. We met some metacharacters



when we discussed wildcards in the previous chapter. Other metacharacters will be



introduced in the Linux shell chapters.



<H3 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Directories: An Overview</FONT></H3>



<P>Linux, like many other computer systems, organizes files in directories. 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 can contain other file folders. In fact, there is no Linux



&quot;filing cabinet&quot;--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.



<H4 ALIGN="CENTER"><A NAME="Heading7<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 subdirectory of directory A, and directory A is the parent



directory of directory B. You will see these terms often, both in this book and elsewhere.



<H4 ALIGN="CENTER"><A NAME="Heading8<FONT COLOR="#000077">The Root Directory</FONT></H4>



<P>In Linux, the directory that holds all the other directories is called the root



directory. This is the ultimate parent directory; every other directory is some level



of subdirectory.</P>



<P>From the root directory, the whole structure of directory upon directory springs



and grows like some electronic elm. This is called a tree structure because, from



the single root directory, directories and subdirectories branch off like tree limbs.



<H4 ALIGN="CENTER"><A NAME="Heading9<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 <TT>-</TT>, <TT>.</TT>, and <TT>_</TT>.</P>



<P>The slash (<TT>/</TT>) character is used to show files or directories within other



directories. For instance, <TT>usr/bin</TT> means that <TT>bin</TT> is found in the



<TT>usr</TT> directory. Note that you can't tell, from this example, whether <TT>bin</TT>



is a file or a directory, although you know that <TT>usr</TT> must be a directory



because it holds another item--namely, <TT>bin</TT>. When you see <TT>usr/bin/grep</TT>,



you know that both <TT>usr</TT> and <TT>bin</TT> must be directories, but again,



you can't be sure about <TT>grep</TT>. The <TT>ls</TT> program shows directories



with a following /--for example, <TT>fido/</TT>. This notation implies that you could



have, for instance, <TT>fido/file</TT>; therefore, <TT>fido</TT> must be a directory.</P>



<P>The root directory is shown simply by the symbol <TT>/</TT> rather than mentioned



by name. It's very easy to tell when <TT>/</TT> is used to separate directories and



when it's used to signify the root directory. If <TT>/</TT> has no name before it,



it stands for the root directory. For example, <TT>/usr</TT> means that the <TT>usr</TT>



subdirectory is found in the root directory, and <TT>/usr/bin</TT> means that <TT>bin</TT>



is found in the <TT>usr</TT> directory and that <TT>usr</TT> is a subdirectory of



the root directory. Remember, by definition the root directory can't be a subdirectory.



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



<P>Linux provides each user with his or her own directory, called the home directory.



Within this home directory, users can store their own files and create subdirectories.



Users generally have complete control over what'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.







<DL>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -