Thursday, January 18, 2007

Handling archive formats in Linux



In Linux , archives and installation packages come in different formats.During installation steps, often handling these files is a tedious process if we dont know the archive formats.Listed here are some of the common archive formats and how to use them in linux for various operations.



ZIP



ZIP files generally use the file extensions ".zip" or ".ZIP" and the MIME media type application/zip.The specification for ZIP indicates that files can be stored either



uncompressed or using a variety of compression algorithms. However, in practice, ZIP is almost always used with Katz's DEFLATE algorithm, except when files being added



are already compressed or are resistant to compression.



ZIP supports a simple password-based symmetric encryption system which is known to be seriously flawed.The most common archive format is the ZIP (*.zip).This is



handled using the program 'zip'.



zip archive.zip file # Create a zip with name archive.zip from file

unzip archive.zip # Extract contents from archivename

man zip # See other options of zip



Also refer :

http://en.wikipedia.org/wiki/ZIP_file_format



TAR



In computing, the tar (file) format (derived from tape archive) is a type of archive bitstream or file format. The format is traditionally produced by the Unix command, tar, and



was standardized by POSIX.1-1998 and later POSIX.1-2001. Initially used for tape backup, it is now commonly used to collate collections of files into one larger file, for



distribution or archiving, while preserving file system information such as user and group permissions, dates, and directory structures.



A tar file (somefile.tar), when subsequently compressed using a zip utility such as gzip or bzip, produces a zipped tar file with a filename extension (e.g.: somefile.tar.gz,



somefile.tar.bz2). A .tar file containing GNU or other program source code is commonly referred to as a tarball, which may be compressed or not.



tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.

tar -tvf archive.tar # List all files in archive.tar verbosely.

tar -xf archive.tar # Extract all files from archive.tar.

man tar # See options



Some compressed forms with TAR and how to extract



* tar file:

.tar

* gzipped tar file:

.tar.gz - gunzip | tar xvf

.tgz - same as above

.tar.gzip - gunzip | tar xvf

.tar.gz.gpg (an encrypted gzipped tar – should be decrypted with GPG)

.war (Konqueror Web ARchive file)

* bzipped tar file:

.tar.bz2 - bunzip2 | tar xvf

.tar.bzip2 - same as above

.tbz2

.tbz

* tar file compressed with compress

.tar.Z - uncompress | tar xvf

.taz - same as above or zcat *.Z | tar -xvf -





refer :

http://en.wikipedia.org/wiki/Tar_%28file_format%29



GZIP



gzip is short for GNU zip, a GNU free software file compression program. It was created by Jean-loup Gailly and Mark Adler. Version 0.1 was first publicly released on



October 31, 1992. Version 1.0 followed in February 1993.gzip File extensions: .gz, .tgz, .tar.gz



The corresponding program for uncompressing gzip'd files is gunzip. Both commands call the same binary; gunzip has the same effect as gzip -d.gunzip takes a list of files



on its command line and replaces each file whose name ends with .gz, -gz, .z, -z, _z or .Z and which begins with the correct magic number with an uncompressed file



without the original extension. gunzip also recognizes the special extensions .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively.When compressing, gzip uses



the .tgz extension if necessary instead of truncating a file with a .tar extension.



gzip file # Create a gzipped archive from file

gunzip archive.gz # Extract files from archive



refer:

http://en.wikipedia.org/wiki/Gzip



BZIP2



bzip2 is a free software/open source data compression algorithm and program developed by Julian Seward.bzip2 compresses most files more effectively than more traditional gzip or ZIP but is slower.File extension: are .bz2, .tar.bz2, .tbz2, .tb2



bzcat archivefile.tar.bz2 | tar -xvf - # to extract from a bzip2-compressed tar-file:



tar -cvf - filenames | bzip2 > archivefile.tar.bz2 # To create a bzip2-compressed tar-file:



tar -xvjf archivefile.tar.bz2 # To deflate in GNU tar



refer:

http://en.wikipedia.org/wiki/Bzip2



For a full list of archive and package formats, refer :

http://en.wikipedia.org/wiki/List_of_archive_formats



Reference : Wikipedia



No comments: