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

📄 541-544.html

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

<HEAD>

<TITLE>Using Linux:System Maintenance</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=0789716232//-->

<!--TITLE=Using Linux//-->

<!--AUTHOR=William Ball//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=31//-->

<!--PAGES=541-544//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch30/533-540.html">Previous</A></TD>

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

<TD><A HREF="544-548.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<H2><A NAME="Heading1"></A><FONT COLOR="#000077">CHAPTER 31<BR>System Maintenance

</FONT></H2>

<P><I>By Tad Bohlsen</I></P>

<DL>

<DD>Compressing and decompressing files and directories

<DD>Compressed archiving with the <TT>tar</TT> command

<DD>Backing up with the <TT>taper</TT> utility

<DD>Using floppy disks and removable drives for backing up

<DD>Maintaining a file system

<DD>Maximizing disk space

<DD>Compressing unused files

</DL>

<H3><A NAME="Heading2"></A><FONT COLOR="#000077">Performing System Backups</FONT></H3>

<P>Making backups is the only way to ensure that you can replace files that become accidentally deleted. To get the most bang for your backup buck (if you can&#146;t back up everything), identify the most important files on your own system. If you use your Linux machine exclusively as a web server, your backup requirements are probably a little different than those of someone who tests software. Try to archive the most critical parts of your system on a regular basis. There is little need to back up applications that you loaded from another storage device (CD-ROM, floppy, and so on) unless you have made major modifications to them. If you are supporting a machine with multiple users, you should definitely set up a backup schedule for the <TT>/home</TT> directory tree.</P>

<H4 ALIGN="LEFT"><A NAME="Heading3"></A><FONT COLOR="#000077">Compressing and Decompressing Files and Directories</FONT></H4>

<P>Often you will need to compress files when backing them up. Compression can also reduce the size of files you are emailing or transferring to someone on diskettes. Linux provides several ways to compress files and directories: The <TT>gzip</TT> (gnu zip) command is generally considered the best of the bunch for most purposes. <TT>gzip</TT>&#146;s alter ego, <TT>gunzip</TT>, decompresses files compressed by <TT>gzip</TT>. <TT>gzip</TT>&#146;s basic syntax is as follows:</P>

<!-- CODE SNIP //-->

<PRE>

#gzip <I>filename</I>

gunzip&#146;s syntax is similar:

#gunzip <I>filename</I>

</PRE>

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

<P><FONT SIZE="+1"><B><I>Using <I>gzip</I> and <I>gunzip</I> to compress and decompress files

</I></B></FONT></P>

<DL>

<DD><B>1.</B>&nbsp;&nbsp;First, choose a file to compress:

<!-- CODE SNIP //-->

<PRE>

#ls &#151;l frankie.txt

--rw--r----r&#150;   1 tb  users        1425 Mar 31 09:22

frankie.txt

</PRE>

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

<DD><B>2.</B>&nbsp;&nbsp;Compress the file using the <TT>gzip</TT> command:

<!-- CODE SNIP //-->

<PRE>

#gzip frankie.txt

</PRE>

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

<DD><B>3.</B>&nbsp;&nbsp;Use <TT>ls</TT> to check the file again (don&#146;t list a filename on the command line). You can see that <TT>gzip</TT> replaces the file whose filename you provide (<TT>frankie.txt</TT> in our example) with a compressed version whose name ends in the suffix <TT>.gz</TT>. The permissions, ownership, and date stamp of the original uncompressed file are retained in the compressed version.

<!-- CODE SNIP //-->

<PRE>

#ls &#151;l

total 1

--rw--r----r&#150;   1 tb   users       705 Mar 31 09:22

frankie.txt.gz

</PRE>

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

<DD><B>4.</B>&nbsp;&nbsp;Use <TT>gunzip</TT> to uncompress the compressed file we just made:

<!-- CODE SNIP //-->

<PRE>

#gunzip frankie.txt.gz

#ls -l

total 1

--rw--r----r&#150;   1 tb users        1425 Apr  1 09:22

frankie.txt

</PRE>

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

<BR>gunzip restores the original filename (removing the <TT>.gz</TT> suffix) and file attributes, removing the compressed file.

</DL>

<P><TT>gunzip</TT> can expand files created with other Linux compression utilities, like the <TT>compress</TT> command. Table 31.1 contains useful command-line options for the <TT>gzip</TT> and <TT>gunzip</TT> commands. You can also use the <TT>info</TT> command to look at online documentation for <TT>gzip</TT>:</P>

<!-- CODE SNIP //-->

<PRE>

<B>#info gzip</B>

</PRE>

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

<TABLE WIDTH="100%">

<CAPTION ALIGN=LEFT><B>TABLE 31.1</B> Commonly used command-line options for <I>gzip</I> and <I>gunzip</I>

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="15%" ALIGN="LEFT">Option

<TH WIDTH="30%" ALIGN="LEFT">Mnenomic

<TH WIDTH="55%" ALIGN="LEFT">Description

<TR>

<TD COLSPAN="3"><HR>

<TR>

<TD VALIGN="TOP"><TT>h</TT>

<TD VALIGN="TOP">help

<TD>Lists command line options for <TT>gzip</TT> and <TT>gunzip</TT>

<TR>

<TD VALIGN="TOP"><TT>v</TT>

<TD VALIGN="TOP">verbose

<TD>When used with <TT>gzip</TT>, produces a verbose information listing, including the name of the compressed file and the degree of compression (as a percentage of the original file size)

<TR>

<TD VALIGN="TOP"><TT>l</TT>

<TD VALIGN="TOP">list

<TD>Lists the original filename(s) of file(s) contained in a compressed file

<TR>

<TD VALIGN="TOP"><TT>t</TT>

<TD VALIGN="TOP">test

<TD>Tests to determine the result of a <TT>gzip</TT> or <TT>gunzip</TT> command. Indicates expected results without actually executing the specified command

<TR>

<TD VALIGN="TOP"><TT>r</TT>

<TD VALIGN="TOP">recursive

<TD>Recursively descends a directory tree, compressing or uncompressing files that match the filename(s) given on the command line

<TR>

<TD VALIGN="TOP"><TT>c</TT>

<TD VALIGN="TOP">concatenate

<TD>Accepts input from the standard input, or places output onto the standard output (allows the use of pipes when generating filenames to be compressed or uncompressed)

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>SEE ALSO</B><BR>&#149; To find out how to use <TT>ls</TT> to list files and directories, see page 31.<HR></FONT>

</BLOCKQUOTE>

<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Compressed Archiving with the <I>tar</I> Command

</FONT></H4>

<P><TT>gzip</TT> does not allow you to easily compress entire directories or directory trees; to compress directories you must also use the <TT>tar</TT> (tape archive) command. <TT>tar</TT> can accept entire filesystems as its input, placing all their directories and files into one file, called a <I>tar file</I>:</P>

<!-- CODE SNIP //-->

<PRE>

#tar -cf tarfile.tar file(s)

</PRE>

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

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="../ch30/533-540.html">Previous</A></TD>

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

<TD><A HREF="544-548.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 + -