Introduction

In some circunstances it’s not easy to know the commands which exist to compress or decompress files in Linux (and Unix) environments.

In this posts, I have wrote all the commands I have used for this.

File Types

TAR files

  • Pack: tar -cvf file.tar file1 file2 file3
  • Unpack: tar -xvf file.tar
  • See content: tar -tf file.tar

GZ files

  • Compress: gzip -9 file
  • Decompress: gzip -d file

BZ2 files

  • Compress: bzip2 file
  • Decompress: bzip -d file.bz2

TGZ (or TAR.GZ) files (TAR+GZIP)

  • Compress+Pack: tar -czf file.tgz file1 file2 file3
  • Decompress+Unpack: tar -xvzf file.tgz
  • See content: tar -tzf file.tgz

TAR.BZ2 files (TAR+BZIP)

  • Compress+Pack: tar -c files | bzip2 > fileo.tar.bz2
  • Decompress+Unpack: bzip2 -cd file.tar.bz2 | tar -xv
  • See content: bzip2 -cd file.tar.bz2 | tar -t

ZIP files

  • Compress+Pack: zip file.zip file1 file2 file3
  • Decompress+Unpack: unzip file.zip

RAR files

  • Compress+Pack: rar -a file.rar file1 file2 file3
  • Decompress+Unpack: rar -x file.rar
  • See content: rar -l file.rar