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

📄 0313-0316.html

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






<HTML>

<HEAD>

<TITLE>Developer.com - Online Reference Library - 0672311623:SAMS TEACH YOURSELF LINUX IN 24 HOURS:Handling Files</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=0672311623 //-->

<!-- TITLE=SAMS TEACH YOURSELF LINUX IN 24 HOURS //-->

<!-- AUTHOR=BILL BALL, STEPHEN SMOOGEN //-->

<!-- PUBLISHER=MACMILLAN //-->

<!-- IMPRINT=SAMS //-->

<!-- PUBLICATION DATE=1998 //-->

<!-- CHAPTER=21 //-->

<!-- PAGES=0313-0328 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->







<P><CENTER>

<a href="../ch20/0311-0312.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0317-0319.html">Next</A>

</CENTER></P>



<A NAME="PAGENUM-313"><P>Page 313</P></A>









<H3><A NAME="ch21_ 2">

Hour 21

</A></H3>



<H2>

<A NAME="ch21_ 3">

Handling Files

</A>

</H2>



<P>This hour continues with the basics of system administration and

introduces you to handling files under Linux. You'll learn how to mount

filesystems, manage the filesystem table (fstab), and format floppies. You'll see how you

can protect files and directories.

</P>



<P>You will use this knowledge to help you administer your Linux

system. Knowing how to manage file ownership is an important Linux skill and can <BR>

help you overcome problems later on.

</P>



<P>One great reason to get up to speed about file access and ownership has to

do with security. There are some important files in your Linux system that,

as root operator, you don't want all users to have access to. If you've set up

your system to handle dial-in calls, you'll want to make sure that important files,

and even other mounted filesystems, such as DOS or Windows, are protected.

If you share your computer, you normally wouldn't want other users to

have access to your files, but on the other hand, you might want to share files

with other people, but don't know how.

</P>



<P>This hour starts with a discussion of the Linux file system.

</P>



<A NAME="PAGENUM-314"><P>Page 314</P></A>







<P>There's a difference between a file system and a filesystem. A

file system is the layout of the directories and hierarchy of files on a partition. A

filesystem is the layout of the lower-level format of a storage device. Linux recognizes a number of filesystems. You can

find a list in the fstab, or filesystem table, manual page under the

/usr/man/man5 directory, but it's best to look at the current list of supported systems in the

mount command manual page. Why? Because the mount command is used to mount the filesystem at a mount point, or

a path you specify. For now, take a look at the Linux file system.

</P>



<H3><A NAME="ch21_ 4">

How Linux Is Organized

</A></H3>



<P>The software that comes with the Linux kernel is from a variety of different UNIX

systems. Some programs, utilities, and commands, like mail or printing, come from a

UNIX distribution, called the Berkeley Software Distribution, or BSD. Other programs

and methods of organizing software, such as startup scripts and organization of files used

during startup, come from either AT&amp;T System V UNIX or later variants. Because of this

mixed heritage, Linux has a mix of directories, and although most pundits say Linux leans

towards being System V-ish, you'll find elements of BSD and System V.

</P>



<P>To give you a better idea, Listin 21.1 contains an edited directory listing, courtesy of

the tree command.

</P>



<P>Listing 21.1. The basic Linux file system, or directory tree.

</P>

<!-- CODE //-->

<PRE>

/ - the root directory

|-- bin - programs considered necessary

|-- boot - Linux boot image

|-- dev - devices, like serial ports, printers, hard drives

|-- etc - configuration files for network, X11, mail, etc.

|-- home - where users live (including sysadmin)

|-- lib - software libraries

|-- lost+found - recovered files (from e2fsck)

|-- mnt - where you mount other filesystems

|   |-- cdrom

|   |-- dos

|   |-- flash

|   &#180;-- floppy

|-- proc - kernel, device, process status files

|-- root - where the sysadmin works, but doesn't live

|-- sbin - system binaries (many root-only)

|-- tmp - temp files stored, deleted from here

|-- usr - hosts much, much software, libraries

|   |-- X11R6 - X Window System software

|   |-- bin - more software

|   |-- dict - dictionaries

|   |-- doc - FAQs, HOW-TOs, software documentation

|   |-- etc - software configuration files

</PRE>

<!-- END CODE //-->



<A NAME="PAGENUM-315"><P>Page 315</P></A>





<!-- CODE //-->

<PRE>

|   |-- games - fun, fun, fun!

|   |-- i486-linuxaout

|   |-- include - header files for programming

|   |-- info - GNU information

|   |-- lib - more software libraries

|   |-- libexec

|   |-- local - programs not on CD-ROM

|   |   |-- bin

|   |   |-- doc

|   |   |-- etc

|   |   |-- games

|   |   |-- info

|   |   |-- lib

|   |   |-- man

|   |   |-- sbin

|   |   &#180;-- src - source code to programs

|   |-- man - manual pages

|   |   |-- man1..9n

|   |-- sbin

|   |-- share

|   |-- src - source for Linux!!!

|   |   |-- linux -&gt; linux-2.0.30

|   |   |-- linux-2.0.30

|   &#180;-- tmp -&gt; ../var/tmp

&#180;-- var - system logs, compressed manual pages

</PRE>

<!-- END CODE //-->



<P>As you can see, the main directory structure is not that complicated. What is

important to understand here is that you should know where you are as you navigate the file

system. When you install software, especially without the benefit of using Red Hat's

rpm package-management command (which you'll learn about in Hour 22, &quot;Red Hat Tools&quot;), you

should know where different software should reside on your system. Many programs will

also require different software components to be installed in different parts of the directory.

</P>



<P>If you look at the file system listing, you'll see a

/mnt, or mount, directory. Although you don't have to use this directory as a gateway to other filesystems, this is traditionally where

other systems are mounted. The next section discusses how to have these other systems

appear under the mount directory.

</P>



<H3><A NAME="ch21_ 5">

Using the mount Command to Access Other Filesystems

</A></H3>



<P>The mount command, found under the /bin

directory, is an essential program used not only by

sysadmins, but also by Linux during startup and shutdown. This command is used

to mount filesystems and make them available in the directory tree. During startup,

the primary Linux partition, an ext2 filesystem, is mounted at the root filesystem, or

/, directory.

</P>



<A NAME="PAGENUM-316"><P>Page 316</P></A>







<P>You can also have other filesystems automatically mounted when Linux starts, or

you mount and unmount filesystems, using the mount and the

umount commands, while you work. The Linux mount command recognizes and will mount (depending on how your kernel

is configured) more than a dozen different filesystems. This section concentrates on the

most common, such as ext2 for Linux, msdos for DOS or Windows, and

iso9660 for CD-ROMs.

</P>



<H3><A NAME="ch21_ 6">

Understanding the Filesystem Table, <BR>

/etc/fstab

</A></H3>



<P>When you start Linux, one of the first scripts to run is the

rc.sysinit script under the /etc/rc.d directory. This script mounts your Linux partition as read-write after it checks the

partition for errors. Then, if everything is OK, it will mount all filesystems described in the

filesystem table, fstab, under the /etc directory with the following command:

</P>

<!-- CODE SNIP //-->

<PRE>

# mount -a -t nonfs

</PRE>

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



<P>This mounts all filesystems described in the

/etc/fstab (except for NFS filesystems; see the

mount command manual page for details). The

/etc/fstab file is a short text file:

</P>

<!-- CODE //-->

<PRE>

# &lt;device&gt;    &lt;mountpoint&gt;   &lt;filesystemtype&gt; &lt;options&gt; &lt;dump&gt; &lt;fsckorder&gt;



/dev/hda3       /                    ext2   defaults,usrquota 1 1

/dev/hdb        /mnt/cdrom           ignore 0 0 0

/dev/cdrom      /mnt/cdrom           iso9660 noauto,ro 0 0

/dev/hda1       /mnt/dos             msdos  defaults 0 0

/dev/hdc1       /mnt/flash           msdos  defaults 0 0

/dev/fd0        /mnt/floppy          ext2   noauto 0 0



none            /proc                proc   defaults

/dev/hda2       none                 swap   sw

</PRE>

<!-- END CODE //-->



<P>The fstab columns show the device, where the filesystem will be mounted, the type

of filesystem, any mount options, whether or not the

dump command (discussed in Hour 23, &quot;Archiving&quot;) needs to check for files to be archived, and the order in which the

filesystem is checked during reboot.

</P>



<P>The fstab rows show a Linux ext2 filesystem, which you configured to support quotas in

the last hour; two CD-ROM devices (/dev/cdrom is a symbolic link to

/dev/hdb); a DOS filesystem partition on the same hard drive as the Linux

ext2 partition; a DOS filesystem on a flash RAM card; the floppy drive; the

/proc directory (used internally by the Linux kernel);

and finally, the Linux swap filesystem.

</P>



<P><CENTER>

<a href="../ch20/0311-0312.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0317-0319.html">Next</A>

</CENTER></P>











</td>
</tr>
</table>

<!-- begin footer information -->









</body></html>

⌨️ 快捷键说明

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