Archive formats

From MineOS Wiki
Jump to navigation Jump to 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.

File formats

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

Compression/Archiving syntax

gzipping a file

gzip filename <syntaxhighlight> $ ls somefile $ gzip somefile $ ls somefile.gz </syntaxhighlight>

bzipping a file

bzip2 filename <syntaxhighlight> $ ls somefile $ bzip2 somefile $ ls somefile.bz2 </syntaxhighlight>

tarballing a file

tar -cf newfilename filetotarball


$ ls somefile $ tar -cf somearchive.tar somefile $ ls somearchive.tar somefile </syntaxhighlight>

tarballing and compressing a directory

tar -czf newfilename somedir <syntaxhighlight> $ ls somedir/ $ tar -czf somearchive.tar.gz somedir $ ls somearchive.tar.gz somedir/ </syntaxhighlight> 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