0% found this document useful (0 votes)
2 views6 pages

Pression

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Pression

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Red Hat Certified

System
Administrator

Compressing and
Decompressing Files
Compression and Archives
There are two topics we need to
cover:

Compression
• Encoding information in fewer bits
than the original information

Archive
• A file that is a collection of a number
of files/directories that can be sorted
easier than its components
Archives
The most common archive
command is tar.
tar stands for, and was originally
used for “Tape Archive”.
Creating an archive:
tar cvf home.tar /home
• create an archive
• verbose
• file name
Extracting an archive:
tar xvf home.tar
• extract an archive
• verbose
• file name
Compression
There are two main compression
commands: gzip and bzip2. They
both do essentially the same thing,
but they use different compression
algorithms.
gzip example:
gzip bigfile.stuff
gzip –d bigfile.stuff.gz

bzip2 example:
bzip2 bigfile.stuff
bzip2 –d bigfile.stuff.bz2
Compress an Archive
While you can compress any file,
you can also just compress an
archive when you create it:
tar czvf home.tar.gz /home
or:
tar cvjf home.tar.bz2 /home

Extracting is the same as you’d


expect:

tar xzvf home.tar.gz /home


or:
tar xvjf home.tar.bz2 /home
zip Files
The other common format for
archival/compression is .zip.
Mostly used for files that need to be
managed on both Windows and
Linux servers, the zip command is
similar to tar in that it will archive
files, but different because it
automatically attempts some
compression.
The archive is unpacked using the
unzip command. Neither zip nor
unzip are normally installed, so
you’ll have to install them to use
them.
Examples:
zip –r archivename /home
unzip archivename

You might also like