Fedora And Red Hat System Administration/Archives And Compression
Compressing Data
This page was last edited 79 months ago, and may be abandoned This page has not been edited since 21 August 2017, but other pages in this book might have been. Check out related changes to see what the state of this book is. You can help by editing and updating this book. Remove {{under construction}} from this page if it is not being actively edited. Ask for help at WB:PROJECTS. |
gzip
and gunzip
Under Construction
bzip2
and bunzip2
Under Construction
tar
- *NIX Archives
Under Construction
Creating a tar
archive
Under Construction
Inspecting a tar
archive
Under Construction
Extracting a tar
archive
Under Construction
cpio
- Flexible Archiving Tool
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
archive
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 cpio
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 cpio
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 archives
Creating a zip
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 zip
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 zip
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
dump
- Filesystem Level Backup
Under Construction