1 / 8

Archiving and Compression

Archiving and Compression. Directory Archive with tar tar • manipulates .tar files, also called tarballs • used for backup and transfer of files • creates, extracts or lists the contents of tarballs • GNU tar supports three builtin compression methods .tar (tarball)

rlajoie
Download Presentation

Archiving and Compression

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Archiving and Compression

  2. Directory Archive with tar • tar • • manipulates .tar files, also called tarballs • • used for backup and transfer of files • • creates, extracts or lists the contents of tarballs • • GNU tar supports three builtin compression methods • .tar (tarball) • • records file and directory structure • • includes metadata about the file: date, timestamps, ownership, permissions, etc. • To make the tarball, if all the files are in the .john/meta/ directory: • $ tar -cf meta.tar /home/john/meta/ • The file meta.tar will be created in the current directory. • To extract the files use the command: • $ tar -xf meta.tar • The files in the meta.tar tarball will be extracted into the current directory. • -t  list the contents of an archive (without extracting) • -v  verbose mode—list archive file names as processed

  3. tar Compression Switches -z GNU gzip -j Modern switch for bzip2

  4. Directory Archive with cpio The cpio format is less commonly used than the tar format for the storage of software for online downloading. However, when used in the context of backing up and restoring files from a tape drive, the cpio format is often used as it is more robust. When encountering a spot on a tape drive with an error, a tar backup will not be able to access anything beyond that point. In comparison with the cpio format, the bad spot on the tape is able to be skipped over and data beyond it retrieved. cpio • manipulates .cpio files • used as the basis for RPM packages • doesn't recurse subdirectories, must be passed list of dirs • more robust than tar when media errors encountered -o  output mode–create a new cpio archive -i  input mode–extract from a cpio archive

  5. The gzip Compression Utility • gzip - popular replacement for compress • gzip [options] filename • • created by the GNU project because of patented algorithms in compress • • default action deletes original after creating new compressed file • • standard file extension: .gz • • much higher compression ratio than compress • The gzip command has the ability to adjust the compression ration. Use the -9 option for highest (and slowest) compression, or use -1 for fastest (and lowest) compression. • gunzip or zcat decompresses files compressed with gzip • • gunzip decompresses the file on disk (removing the original, compressed file); zcat does not • • zcat outputs uncompressed data to STDOUT

  6. Using gzip with the tar Command Adding the -z option to tar enables automatic gzip compression and decompression: $ tar -zcf backup.tar.gz /home/john/ The file can be extracted in the same manner: $ tar -zxf backup.tar.gz Note that gzip-compressed tarballs commonly are named with either .tgz or .tar.gz extensions.

  7. The bzip2 Compression Utility • bzip2 - Latest and greatest compression • • typically better compression than the gzip command • • default action deletes original after creating new compressed file • • standard file extension: .bz2 • bunzip2 or bzcat decompresses files compressed with bzip2 • • bunzip2 decompresses the file on disk (removing the original, compressed file); bzcat does not • • bzcat outputs uncompressed data to STDOUT • Replaces gzip as compression format of choice • Using bzip2 with the tar Command • Adding the -j option to tar enables automatic bzip2 compression and decompression: • $ tar -jcf backup.tar.bz2 /home/john/ • The file can be extracted in the same manner: • $ tar -jxf backup.tar.bz2

  8. The zip Compression Utility zip - Compatible with ZIP files • default action deletes original after creating new compressed file • standard file extension: .zip unzip expands a .zip file

More Related