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

📄 rhl37.htm

📁 linux的初学电子书
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<BR>

<P>You can't just turn off the power switch! This can cause damage to the file system, sometimes irreversibly. Because Linux keeps many files open at once, as well as several processes, they must all be closed down properly before you cycle the power to 
the unit.

<BR>

<P>There are a few ways to shut the Linux system down, but the formal method is to use the shutdown command. The syntax for shutdown is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">shutdown [minutes] [warning]</FONT></PRE>

<P>where minutes is the number of minutes to wait before shutting the system down and warning is an optional message displayed for all users currently logged in. Some versions of shutdown allow the word now instead of a time, while others require either no 
argument or the number 0 to shut the system down immediately without waiting. You can have shutdown reboot the system after the shutdown by adding the argument -r (for reboot).

<BR>

<P>Using shutdown is best if you have other users on your system, because it gives them a warning that they should log out, and it prevents loss of information. It can also be used to automate a shut-down much later (such as at midnight), with messages 
just before that time warning any users still logged in.

<BR>

<P>If you can't wait and want to shut the system down immediately, use the halt command or the &quot;three-finger salute&quot; of Ctrl-Alt-Delete. This immediately shuts down all the processes and halts the system as quickly as possible. Then the power can 
be shut off.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>Some Linux distributions don't support Ctrl-Alt-Delete, and a couple of older distributions use it to halt the system immediately without terminating processes properly. This can cause damage. Check the documentation or man pages for 
information.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<BR>

<A NAME="E68E321"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Mounting File Systems</B></FONT></CENTER></H3>

<BR>

<P>File systems are not available until they are mounted onto the Linux main file system. Even hard drives must be mounted, because only the root file system is available in the / directory until the rest are mounted. The mount command is used to mount a 
file system.

<BR>

<P>During the boot process, the mount command is used from the startup files (such as the /etc/rc file or files under the /etc/rc.d directory) to mount all the File Systems maintained in the file /etc/fstab. You can look at the file to see the type of 
information maintained there. Every file system that is mounted during the boot process has an entry giving its device name, its mount directory (called the mount point), the type of file system it is, and any options that apply.

<BR>

<P>You can add a new file system from a hard disk, a CD-ROM, a floppy, or any other type of device that provides a file system supported by Linux, using the mount command. The format is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mount filesystem mountpoint</FONT></PRE>

<P>where filesystem is the name of the device and mountpoint is where in the Linux file system it should be mounted. For example, if you want to mount a SCSI CD-ROM to the file system as /usr/cdrom, issue the following command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mount /dev/scd0 /usr/cdrom</FONT></PRE>

<P>The directory /usr/cdrom must be created before the command is given, or the mount command will generate an ambiguous error. You should replace /dev/scd0 with the name of your CD-ROM device driver (/dev/cd0 for most non-SCSI CD-ROM drives, and /dev/scd0 
for SCSI CD-ROM drivers). When the file system has been mounted properly, changing to /usr/cdrom lets you access all the files on the CD-ROM as if they were part of the normal file system.

<BR>

<P>If your /etc/fstab file doesn't have any entries in it already, you have to mount the file system with a slightly different syntax:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mount -t fstypefilesystem mountpoint</FONT></PRE>

<P>where fstype is the type of file system (such as ISO9660, MSDOS, and so on). The rest of the arguments are the same as the previous example. The -t option is used when the file system to be mounted doesn't already have an entry in the /etc/fstab file.

<BR>

<BR>

<A NAME="E69E416"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Mounting a Floppy</B></FONT></CENTER></H4>

<BR>

<P>You can mount a floppy disk with a command similar to the one in the CD-ROM example just discussed. To mount a floppy in the first floppy drive on the directory /mnt, issue the following command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mount /dev/fd0 /mnt</FONT></PRE>

<P>If the file system is not the default value used by Linux, the type of file system must be specified. For example, to mount a floppy using the ext2 file system, use the -t option of the mount command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mount -t ext2 /dev/fd0 /mnt</FONT></PRE>

<BR>

<A NAME="E69E417"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Creating a New File System</B></FONT></CENTER></H4>

<BR>

<P>To create a file system on a floppy (so it can be mounted), you should use the utility mke2fs or the command mkdev fs, depending on the version of Linux. To use mke2fs, for example, issue the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mke2fs /dev/fd0 1440</FONT></PRE>

<P>to create a floppy file system on a 1.44MB 3.5-inch diskette.

<BR>

<BR>

<A NAME="E69E418"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Unmounting File Systems</B></FONT></CENTER></H4>

<BR>

<P>To detach a mounted file system from your Linux file system, use the umount command with the name of the device. For example, to unmount a floppy in /dev/fd0, issue the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">umount /dev/fd0</FONT></PRE>

<P>and the floppy will be removed from the mounted point. Be sure to type umount instead of unmount!

<BR>

<P>If you want to remove the current floppy and replace it with another, you can't simply swap them. The current floppy must be unmounted, and then the new one must be mounted. Failure to follow this process can result in corruption or erroneous directory 
listings.

<BR>

<BR>

<A NAME="E69E419"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Checking File Systems</B></FONT></CENTER></H4>

<BR>

<P>Every now and again a file might get corrupted or a file system's inode table might get out of sync with the disk's contents. For these reasons, it is a good idea to check the file system at regular intervals. Several utilities can check file systems, 
depending on the version of Linux. The utility fsck is available for some systems, while the utility e2fsck is designed for Linux's ext2fs file system. Many Linux versions include other utilities such as xfsck and efsfck for different file systems. In many 
cases, the fsck command is linked to the individual file system versions.

<BR>

<P>To use e2fsck to check a file system, issue the command with the device name and the options a (automatically correct errors) and v (verbose output):

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">e2fsck -av /dev/hda1</FONT></PRE>

<P>This command checks and repairs any problems on the /dev/hda1 (or whatever device driver you specify) partition. If any corrections have been made to a partition, you should reboot the machine as soon as possible to allow the system to resync its 
tables.

<BR>

<P>Whenever possible, it is a good idea to unmount the file system before checking it, because this can prevent problems with open files. Of course, you can't unmount the primary root partition while running from it, so you can boot from a boot floppy that 
contains the check utilities, and start them from the floppy.

<BR>

<BR>

<A NAME="E69E420"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Using a File as Swap Space</B></FONT></CENTER></H4>

<BR>

<P>When you installed Linux, your setup program probably set up a partition specifically for the swap space. You can, when the original installation has been completed, set Linux to use a file instead of the partition, thus freeing up the partition's disk 
space.

<BR>

<P>Generally, there is a performance degradation with using a file because the file system is involved, although the effect can be small on fast disks and CPUs. However, this is a useful technique when you need to add more swap space, such as when you 
temporarily want to run a swap-space-intensive application such as a compiler.

<BR>

<P>To create a file used as the swap space, issue the following command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">dd if=/dev/zero of=/swap bs=1024 count=16416</FONT></PRE>

<P>This creates a file (called swap) for swap space that is about 16MB (in this case, 16416 blocks). If you want a different size, replace the number after count with the correct value in bytes. Next, physically create the file swap file with the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">mkswap /swap 16416</FONT></PRE>

<P> (the number should match the blocks determined earlier) and turn the swap space on with the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">swapon /swap</FONT></PRE>

<P>If you want to remove the swap file and use the swap partition, use the command

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">swapoff /swap</FONT></PRE>

<P>followed by a standard rm command to remove the file.

<BR>

<P>Swap files can't be larger than 16MB with most Linux versions, but you can have up to eight swap files and partitions on your system.

<BR>

<BR>

<A NAME="E68E322"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Compressing Files with </B><B>gzip</B><B> and </B><B>compress</B></FONT></CENTER></H3>

<BR>

<P>Files abound on a UNIX system, adding up to a large chunk of disk real estate. Instead of deleting files, an alternative is to compress them so that they take up less space. Several compression utilities are available for UNIX and Linux systems. The 
most commonly used are compress and the newer GNU gzip.

<BR>

<P>When run on a file, compress creates a smaller file with the extension .Z, which immediately identifies the file as being compressed. To compress a file, use the following command:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">compress filename</FONT></PRE>

<P>You can also use wildcards to compress several files at once. compress supports a number of options, but most aren't used often. By default, when a file is compressed, the uncompressed original is deleted, although this can be changed with a 
command-line option.

<BR>

<P>To uncompress a compressed file, run the uncompress program:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">uncompress filename</FONT></PRE>

<P>Alternatively, you can use a wildcard such as *.Z to uncompress all the compressed files. Remember to include the .Z suffix when specifying the filename.

<BR>

<P>The gzip utility is a new compression tool that uses different algorithms than compress. The gzip program has a few extra features that were added since compress was released, such as adjustable compression (the more compression required, the longer it 
takes to compress). To use gzip, specify the filename to be compressed and the compression type:

<BR>

<BR>

<PRE>

⌨️ 快捷键说明

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