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

📄 544-548.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=544-548//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="541-544.html">Previous</A></TD>

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

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

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P>This command creates (<TT>-c</TT>) an archive file (<TT>f tarfile.tar</TT>) containing all the listed files. The <TT>file(s)</TT> argument can be a directory in a directory tree; <TT>tar</TT> archives everything beneath that directory (inclusive), maintaining all the directory relationships, including links, permissions, ownership information, and date stamps. To tell <TT>tar</TT> exactly what type of archiving job to perform, specify one function as the first argument on the command line (see Table 31.1 for a list of <TT>tar</TT>&#146;s major function identifiers).</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>TABLE 31.2</B> <I>tar</I>&#146;s major function identifiers

<TR>

<TH COLSPAN="3"><HR>

<TR>

<TH WIDTH="30%" ALIGN="LEFT">Function Identifier

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

<TH WIDTH="45%" ALIGN="LEFT">Action

<TR>

<TD COLSPAN="3"><HR>

<TR>

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

<TD VALIGN="TOP">create

<TD>Instructs <TT>tar</TT> to make a new archive, putting the listed files and directories in the <TT>tar</TT> file you designate

<TR>

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

<TD VALIGN="TOP">extract

<TD>Instructs <TT>tar</TT> to recreate a set of original files (and directories) using the specified <TT>tar</TT> archive file

<TR>

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

<TD VALIGN="TOP">list

<TD>Generates a list of the listed files that are stored in the <TT>tar</TT> file (if no files are listed on the command line, lists all files in <TT>tar</TT>)

<TR>

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

<TD VALIGN="TOP">update

<TD>Updates an existing <TT>tar</TT> file with the files listed if they are not currently contained in the <TT>tar</TT> file, or have more recent modification times (m times) than the file(s) already contained in the <TT>tar</TT> file

<TR>

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

<TD VALIGN="TOP">append

<TD>Adds listed files to the end of an existing <TT>tar</TT> archive file

<TR>

<TD COLSPAN="3"><HR>

</TABLE>

<P>In addition to using functions to designate the major action it will perform, <TT>tar</TT> accepts dozens of additional options. Listed here are some of the ones most often used:</P>

<TABLE WIDTH="80%"><TR>

<TD WIDTH="35%"><TT>f filename</TT>

<TD WIDTH="65%">Designates <TT>tar</TT> filename

<TR>

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

<TD>Keeps old files (doesn&#146;t overwrite with files being extracted)

<TR>

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

<TD>Verbose (provides information while running)

<TR>

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

<TD>Archives/extracts by using <TT>gzip</TT> compression/decompression

<TR>

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

<TD>Multivolume (indicates an archive that can use several floppy disks or tapes)

<TR>

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

<TD>Volume name (stored in <TT>tar</TT> file for reference)

</TABLE>

<P><FONT SIZE="+1"><B>Using <I>tar</I> to Archive Directories

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

<P><TT>tar</TT> can archive an entire directory if you use a directory name on the command line:</P>

<!-- CODE //-->

<PRE>

#pwd

/public/sharedfiles/me



#ls -l

total 27

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

README.txt

&#151;rwxrwxr&#151;x   1 me       me           1519 Mar 15 21:29

iousage

drwxrwxr&#151;x   2 me       users        1024 Jun  8  1996

fileshare

lrwxrwxr&#151;x   2 me       users           8 Dec 12 20:39

thtfil -&gt; thisfile



# tar cf share.tar /public/sharedfiles/me

tar: removing leading / from absolute pathnames in the archive



#ls -l

total 28

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

README.txt

&#151;rwxrwxr&#151;x   1 me       me           1519 Mar 15 21:29

iousage

drwxrwxr&#151;x   2 me       users        1024 Jun  8  1996

fileshare

&#151;rwxrwxr&#151;x   1 me       users       46058 Apr  1 20:40

share.tar

lrwxrwxr&#151;x   2 me       users           8 Dec 12 20:39

thtfil -&gt; thisfile

</PRE>

<!-- END CODE //-->

<P><TT>tar</TT> uses relative pathnames; it creates an archive of the <TT>me</TT> directory in the preceding code without referring to the root pathname (the first slash). (That&#146;s what the <TT>tar: ...</TT> system message means.) You can place archived directories in other directories without worrying about the archive&#146;s original pathnames and parent directories.</P>

<P>You can think of <TT>tar</TT> as a way to graft a directory branch to another directory tree; you can use one <TT>tar</TT> file to move an entire set of directories and subdirectories from place to place on your system, or from system to system (many ftp files are <TT>tar</TT> files).</P>

<P><FONT SIZE="+1"><B>Moving and Extracting <I>tar</I> Files

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

<P>After you create a <TT>tar</TT> file, anyone with read and write permissions for the directory containing the file (such as the user <TT>notme</TT>) needs to add the <TT>me</TT> directory that was archived earlier to his or her home directory:</P>

<!-- CODE //-->

<PRE>

#pwd

/home/notme



#ls -l

total 53

&#151;rw&#151;rw&#151;r&#150;   1 notme    users     8432 Apr 1 20:40

zipcode.c

&#151;rw&#151;rw&#151;r&#150;   1 notme    users    21519 Mar 14 21:29

stadd.o

drwxrwxr&#151;x   2 notme    users     1024 Dec  4 20:39

docfiles

drwxr-xr&#150;   1 notme    users     1024 Jan 11  1996

perlscripts

drw&#151;r---r&#150;   2 notme    users     1024 Mar 14 21:29

progfiles



#cp /public/sharedfiles/me/share.tar .



#tar xvf share.tar

public/sharedfiles/me/README.txt

public/sharedfiles/me/iousage

...



#ls -l

total 80

&#151;rw&#151;rw&#151;r----   1 notme    users     8432 Apr  1 20:40

zipcode.c

&#151;rw&#151;rw&#151;r----   1 notme    users    21519 Mar 14 21:29

stadd.o

drwxrwxr&#151;x   2 notme    users     1024 Dec  4 20:39

docfiles

drwxr-xr----   1 notme    users     1024 Jan 11  1996

perlscripts

drw&#151;r---r----   2 notme    users     1024 Mar 14 21:29

progfiles

drwxrwxrwx   2 notme    users     1024 Apr  1  1996 public



#ls -l public

drwxrwxr-x   2 notme    users     1024 Aug  17 08:42 me

</PRE>

<!-- END CODE //-->

<P>Because the user <TT>notme</TT> ran the <TT>tar</TT> extraction command, the extracted directory <TT>public</TT> (and its subdirectories) are now owned by <TT>notme</TT> rather than <TT>me</TT>. The <TT>v</TT> (verbose) option in the last example provides a listing of relative pathnames for each file <TT>tar</TT> processes (abbreviated for space). Increasing the number of <TT>v</TT> options listed increases the amount of information <TT>tar</TT> provides (<TT>vv</TT> lists date stamps and sizes as well as pathnames, like the <TT>ls -l</TT> command).</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="541-544.html">Previous</A></TD>

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

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