Archiving in Linux

From StdOut

An archive file is a file that is composed of one or more computer files along with metadata. Archive files are used to collect multiple data files together into a single file for easier portability and storage, or simply to compress files to use less storage space. Archive files often store directory structures, error detection and correction information, arbitrary comments, and sometimes use built-in encryption. (source: Wikipedia)

tar.gz

Create

tar zcvf archive.tar.gz /path/to/archive
  • z: gzip
  • c: create
  • v: verbose
  • f: file

Extract

tar zxvf archive.tar.gz (-C /path/to/destination)
  • z: gzip
  • x: extract
  • v: verbose
  • f: file
  • C: directory

tar.bz2

Create

tar jcvf archive.tar.bz2 /path/to/archive
  • j: bzip2
  • c: create
  • v: verbose
  • f: file

Extract

tar jxvf archive.tar.bz2 (-C /path/to/destination)
  • j: bzip2
  • x: extract
  • v: verbose
  • f: file
  • C: directory

.zip

Extract

unzip archive.zip (-d /path/to/destination)
  • d: exdir

.rar

Extract

unrar e/x archive.rar
  • e: extract files to current directory
  • x: extract files with full path

.7z

Extract

7z e/x archive.7z
  • e: extract files from archive (without using directory names)
  • x: extract files with full path