Search Engine

Loading

Sallar

Sallar
RedhatEnterpriseLinux Blog

The tar Utility and compression


 The tar Utility
When backing up data that is no longer being used or data that is not frequently changed, consider creating a compressed archive file using the tar archive utility in combination with one of the compression tools such as gzip or bzip2. Creating a compressed archive file results in one file that must be decompressed and unarchived before files can be restored from it. The compression of the files saves room on the backup media. To use tar, the tar RPM package must be installed. It should be installed on your system unless you chose to only install a specific set of packages. The tar utility does not preserve access control lists.


To archive a set of files and compress it with bzip2:
tar cjvf <filename>.tar.bz <files>
The tar arguments used are as follows:
. c: create the archive
. j: use bzip2 compression
. v: be verbose and show the progress
. f: files to archive will follow

A filename for the compressed archive must be given. Try to be as descriptive yet brief as possible. The commonly used extension for a tar file compressed with bzip2 is .tar.bz. For <files>, multiple files and directories can be specified. If a directory is specified, all the files and subdirectories are archives as well by default.
To uncompressed and unarchived a tar file compressed with bzip2:

tar xjvf <filename>.tar.bz

When the files are unarchived, the original directory structure is retained. For example, if you specified the directory templates/ as the files to be archived, when the tar file is unarchived, the directory templates/ is created in the current working directory, and all the original files in the directory are written in the newly created directory.
File ownership is also retained by UID and GID. Keep in mind that if a tar file is created on one system and then unarchived on a different system, the file ownership might change if the UID or GID is mapped to a different user or group on the second system.
To list the contents of the file without uncompressing or unarchiving it:

tar tjvf <filename>.tar.bz

0 comments:

Post a Comment

Powered by Blogger.

Ads

 
Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: www.redhatenterpriselinux.blogspot.com I live in Quetta, Pakistan and work as an IT-Engineer.