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

📄 550-554.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=550-554//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="548-550.html">Previous</A></TD>

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

<TD><A HREF="554-557.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>There are more options available for the <TT>find</TT> command than for almost any other Linux utility. See Table 31.3 for useful search rules to use with <TT>find</TT>.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>TABLE 31.3</B> <I>find</I> command search expressions

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="40%" ALIGN="LEFT">Expression

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

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

<TR>

<TD COLSPAN="3"><HR>

<TR>

<TD VALIGN="TOP"><TT>-atime/-mtime/-ctime</TT>

<TD VALIGN="TOP">test

<TD>Tests whether file(s) were created before (<TT>&#43;n</TT>), after (<TT>-n</TT>) or on (<TT>n</TT>), where <TT>n</TT> is an integer representing <TT>n</TT> number of days before today. (For example, <TT>-ctime -5</TT> would find all files changed within the last five days.)

<TR>

<TD VALIGN="TOP"><TT>-depth</TT>

<TD VALIGN="TOP">option

<TD>Processes the files in each directory before checking the permissions of the directory itself.

<TR>

<TD VALIGN="TOP"><TT>-exec command {} \;</TT>

<TD VALIGN="TOP">action

<TD>Executes command for each file passed to it.

<TR>

<TD VALIGN="TOP"><TT>-group groupname</TT>

<TD VALIGN="TOP">test

<TD>Tests whether files are owned by group <TT>groupname</TT>.

<TR>

<TD VALIGN="TOP"><TT>-name filename</TT>

<TD VALIGN="TOP">test

<TD>Tests whether filenames passed to it match <TT>filename</TT>.

<TR>

<TD VALIGN="TOP"><TT>-nouser</TT>

<TD VALIGN="TOP">test

<TD>Tests for files with no user associated; useful for finding &#147;orphaned&#148; files that could be archived or deleted.

<TR>

<TD VALIGN="TOP"><TT>-ok command {} \;</TT>

<TD VALIGN="TOP">action

<TD>Like <TT>exec</TT>, except prompts user before executing command on each file passed to it.

<TR>

<TD VALIGN="TOP"><TT>-path pathname</TT>

<TD VALIGN="TOP">test

<TD>Tests whether the path of the file(s) passed to it matches <TT>pathname</TT>.

<TR>

<TD VALIGN="TOP"><TT>-prune</TT>

<TD VALIGN="TOP">action

<TD>Skips directories passed to it (often used with <TT>-path</TT>, where <TT>-path</TT> identifies the directory to skip and passes the name to <TT>prune</TT>).

<TR>

<TD VALIGN="TOP"><TT>-regex expression</TT>

<TD VALIGN="TOP">test

<TD>Tests whether the filename(s) passed to it match a regular expression.

<TR>

<TD VALIGN="TOP"><TT>-size nk</TT>

<TD VALIGN="TOP">test

<TD>Tests whether files passed to it are <TT>n</TT> KB in size (can use <TT>&#43;n</TT> or <TT>-n</TT> for greater or less than <TT>n</TT>).

<TR>

<TD VALIGN="TOP"><TT>-type d</TT>

<TD VALIGN="TOP">test

<TD>Tests whether files are of type <TT>d</TT> (directories).

<TR>

<TD><TT>-user username</TT>

<TD VALIGN="TOP">test

<TD>Tests whether files are owned by user <TT>username</TT>.

<TR>

<TD VALIGN="TOP">-xdev

<TD VALIGN="TOP">option

<TD>Instructs <TT>find</TT> to search on the current device only (for example, only on the hard drive).

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<P><FONT SIZE="+1"><B>Locating Files Based on Their Access Times</B></FONT></P>

<P>You&#146;ve seen how <TT>find</TT> can locate files based on their access times (for example, the most recent time the file was accessed, or used) in Chapter 3, &#147;Navigating the Linux File System.&#148;</P>

<!-- CODE SNIP //-->

<PRE>

#find /dev -atime &#43;30 -print

</PRE>

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

<P>This command prints to the screen the device files that haven&#146;t been accessed for the past 30 days. You can build a list of files to archive based on their most recent access times. However, it&#146;s sometimes necessary to change files&#146; access times to make sure the <TT>find</TT> command locates them during a search.</P>

<P>To update a file&#146;s access times, use the <TT>touch</TT> command:</P>

<!-- CODE SNIP //-->

<PRE>

#touch $HOME/*

</PRE>

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

<P>Using the <TT>touch</TT> command like this changes the access times of all files in your home directory to the current system time.</P>

<P>You can then use the <TT>tar</TT> command to select files based on access times when archiving.</P>

<!-- CODE SNIP //-->

<PRE>

#ls -l $HOME

total 2

&#151;rwxrwxr&#151;x   1 me       users       22843 Apr  1  9:40

README.txt

&#151;rwxrwxr&#151;x   1 me       me           1519 Apr  1  9:40

iousage



#tar -cvz -N DATE -f home.tar.gz $HOME

</PRE>

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

<P>The <TT>N</TT> option tells <TT>tar</TT> to archive only those files with access times more recent than <TT>DATE</TT>, where the date is given in the format of the <TT>date</TT> command.</P>

<P>For more information about the <TT>find</TT> and <TT>tar</TT> commands, consult their respective man pages.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>SEE ALSO</B>

<DL>

<DD><B>&#149;</B>&nbsp;&nbsp;For more information about regular expressions, see page 25.

<DD><B>&#149;</B>&nbsp;&nbsp;For more information about file attributes (date stamps, permissions, and ownership) see page 43  and page 418.

<DD><B>&#149;</B>&nbsp;&nbsp;For more information about the <TT>touch</TT> command and file <TT>date</TT> stamps, see page 36.

</DL>

<HR></FONT>

</BLOCKQUOTE>

<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Using <I>taper</I> for Backups

</FONT></H4>

<P>Red Hat Linux 5.0 includes a backup utility developed by Yusuf Nagree called <TT>taper</TT>. You can use the Red Hat package manager utility, <TT>rpm</TT>, to query whether the <TT>taper</TT> package was installed on your system with Red Hat Linux 5.0.</P>

<!-- CODE SNIP //-->

<PRE>

#rpm -q taper

taper-6.8.0a10-1

</PRE>

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

<P>If you do not have the <TT>taper</TT> package installed, you can use the <TT>rpm</TT> or <TT>glint</TT> utility to install it.</P>

<P>You can run the <TT>taper</TT> utility entirely from the command line, but it is made to use a menuing system. The main piece of information you must supply is the type of backup device you use.</P>

<!-- CODE SNIP //-->

<PRE>

#taper -T device type indicator

</PRE>

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

<P>Table 31.4 lists the device types you can use with <TT>taper</TT>, and the device type indicator for each.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>TABLE 31.4</B> Device type options to use when starting <I>taper</I>

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Device Indicator

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

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

<TR>

<TD COLSPAN="3"><HR>

<TR>

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

<TD VALIGN="TOP">zftape

<TD>Newest floppy drive tape driver, recommended for use if you have the <TT>zftape</TT> device driver

<TR>

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

<TD VALIGN="TOP">ftape

<TD>Older floppy drive tape driver, use if the <TT>ftape</TT> version you use is earlier than version 3.0

<TR>

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

<TD VALIGN="TOP">removable

<TD>Use when backing up to floppies and other removable devices (like Zip drives)

<TR>

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

<TD VALIGN="TOP">scsi

<TD>Use with SCSI tape drives

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="548-550.html">Previous</A></TD>

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

<TD><A HREF="554-557.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 + -