Archive formats

From MineOS
Jump to: navigation, search

Dozens of archive formats exist, such as 'zip' which is commonly used on Windows. In fact, .zip files are archived and compressed. However, in an effort to keep true to Linux's dedication to specialization, Linux instead uses one format for each task. Luckily, with how Linux piping is designed, despite two different tasks to the computer it is still only one task to the user.

Contents

File formats

gzip
A compression algorithm that produces a file with extension .gz
bzip2
A compression algorithm that produces a file with extension .bz2
tar
Creates a tarball archive--a collection of files with no compression

Compression/Archiving syntax

gzipping a file

gzip filename

$ ls
somefile
$ gzip somefile
$ ls
somefile.gz

bzipping a file

bzip2 filename

$ ls
somefile
$ bzip2 somefile
$ ls
somefile.bz2

tarballing a file

tar -cf newfilename filetotarball

$ ls
somefile
$ tar -cf somearchive.tar somefile
$ ls
somearchive.tar somefile

tarballing and compressing a directory

tar -czf newfilename somedir

$ ls
somedir/
$ tar -czf somearchive.tar.gz somedir
$ ls
somearchive.tar.gz somedir/

Note: the -z argument means that as each file is archived, it is also compressed with gzip. Thus, you can choose the new archive file to have the extension '.tgz' or '.tar.gz'

Decompression/Extracting syntax

gunzipping a file

  • gunzip filename.gz

buzipping a file

  • bunzip2 filename.bz2

un-tarring a file

  • tar xvf filename.tar.gz

un-tarring and gunzipping a file

  • tar xvzf filename.tar.gz
  • tar xvzf filename.tgz

un-tarring and bunzipping a file

  • tar xvjf filename.tar.bz2