Fedora And Red Hat System Administration/Archives And Compression

and
Under Construction

and
Under Construction

- *NIX Archives
Under Construction

Creating a archive
To create an uncompressed  archive, the  and   options are provided (think 'c' for create and 'f' for filename):

The first argument is the name of the archive, in this case. Any following arguments are the files that are being archived (e.g. ). Usually globbing is used to archive all files of a particular type (e.g.  will archive all of the .cpp files     in the current directory):

To archive all files and subdirectories within a directory, the same options are provided, but the second argument is the  character which symbolizes the current working directory:

To compress the contents of the archive one of the,  , or   options are used. Each option corresponds to a different compression algorithm, which in order are:,  , and.

For example, to create a  compressed archive of the current directory the following would be run:

Inspecting a archive
Under Construction

Extracting a archive
Under Construction

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

Creating a archive
To create a  archive, the   option is provided (think 'o' for "The archive is being written o ut"). 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  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
To view the contents of an archive the  option is provided to tell  to expect the archive data on its standard input. The  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 &lt;archive playground/ playground/AUTHORS playground/ChangeLog playground/COPYING playground/foo.txt playground/newfile 1212 blocks

Extracting an archive with
The  option is used with a combination of options to tell it how to extract. Common choices include  to tell cpio to create directories as needed. to reset file modification times. to change file ownership.

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

Creating a archive
[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 archive
[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 archive
[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

- Filesystem Level Backup
Under Construction