Fedora And Red Hat System Administration/Archives And Compression

Compressing DataEdit

Under Construction

gzip and gunzipEdit

Under Construction

bzip2 and bunzip2Edit

Under Construction

tar - *NIX ArchivesEdit

Under Construction

Creating a tar archiveEdit

Under Construction

Inspecting a tar archiveEdit

Under Construction

Extracting a tar archiveEdit

Under Construction

cpio - Flexible Archiving ToolEdit

In general, tar is the preferred method for creating archives, but in some cases a particular archive format may be desired and cpio provides a greater degree of control over how the archive is generated at the cost of greater complexity.

Creating a cpio archiveEdit

To create a cpio archive, the -o option is provided (think 'o' for "The archive is being written out"). cpio expects a list of files to be provided to its standard input. The list of files is usually provided by piping results from the find command. The -H option can be used to specify the archive format, see the man page for more information.

[user@station user]$ find playground/
playground/
playground/AUTHORS
playground/ChangeLog
playground/COPYING
playground/foo.txt
playground/newfile
[user@station user]$ find playground/ | cpio -o >archive
1212 blocks
[user@station user]$ ls -l archive
-rw-rw-r--    1 user     user       620544 Jan  5 08:49 archive
[user@station user]$ file archive
archive: cpio archive

Listing contents of an archive with cpioEdit

To view the contents of an archive the -i option is provided to tell cpio to expect the archive data on its standard input. The -t option is also used then to tell cpio to not extract, but rather simply list the contents of the archive.

[user@station user]$ cpio -it <archive
playground/
playground/AUTHORS
playground/ChangeLog
playground/COPYING
playground/foo.txt
playground/newfile
1212 blocks

Extracting an archive with cpioEdit

The -i option is used with a combination of options to tell it how to extract. Common choices include -d to tell cpio to create directories as needed. -m to reset file modification times. -R to change file ownership.

[user@station user]$ cd /tmp
[user@station tmp]$ cpio -idm <archive
1212 blocks
[user@station tmp]$ find playground/
playground/
playground/AUTHORS
playground/ChangeLog
playground/COPYING
playground/foo.txt
playground/newfile

zip - PKZIP style archivesEdit

Creating a zip archiveEdit

[user@station user]$ zip -r playground.zip playground
  adding: playground/ (stored 0%)
  adding: playground/AUTHORS (deflated 63%)
  adding: playground/COPYING (deflated 62%)
  adding: playground/foo.txt (stored 0%)
  adding: playground/newfile (deflated 39%)
  adding: playground/ChangeLog (deflated 70%)
[user@station user]$ ls -l playground.zip
-rw-r--r--  1 user     user     71607 Jan 11 14:33 playground.zip

Listing contents of a zip archiveEdit

[user@station user]$ unzip -l playground.zip
Archive:  playground.zip
  Length     Date   Time    Name
 --------    ----   ----    ----
        0  01-11-05 14:33   playground/
     2110  01-11-05 14:32   playground/AUTHORS
    17992  01-11-05 14:33   playground/COPYING
       22  01-11-05 14:33   playground/foo.txt
       44  01-11-05 14:33   playground/newfile
   212169  01-11-05 14:32   playground/ChangeLog
 --------                   -------
   232337                   6 files

Unpacking a zip archiveEdit

[user@station user]$ rm -rf playground
[user@station user]$ unzip playground.zip
Archive:  playground.zip
   creating: playground/
  inflating: playground/AUTHORS
  inflating: playground/COPYING
 extracting: playground/foo.txt
  inflating: playground/newfile
  inflating: playground/ChangeLog

dump - Filesystem Level BackupEdit

Under Construction

Last modified on 30 June 2006, at 18:33