Compression and decompression with the Linux Shell

December 2016




Here are some commands to compress and decompress files and folder on Linux:
  • gunzip file.gz: Uncompress a file or folder (.gz or .tgz)
  • unzip file.zip: Unzip a file or folder in zip format.
  • uncompress file.Z:Extracts a file or folder in .Z
  • zip arch.zip files: Compress a file or folder in zip format.
  • gzip file: Compress a file or folder in .gz
  • compress file: Compress a file or folder in .Z
  • tar -cf arch.tar rep : Create an archive of the "dir" directory
  • tar -tf arch.tar: Examine the contents of the arch.tar archive
  • tar -xf arch.tar: Extract the arch.tar archive
  • tar -xf arch.tar -C /home:Extracts a file or folder in /home (for recent versions of tar)
  • cd /home; tar -xf: archive.tar:Extracts a file or directory in /home (all version)
  • tar -xpf archive.tar:Extracts a file or folder while keeping as much as possible the rights (including flags set-UID)
  • tar -xzf file.tgz:Extracts a file or file format .tgz or .gz (recent versions of tar)
  • gunzip file.tgz | tar -xf-:Extracts a file or folder in .tgz or .gz (all versions)
  • tar -xjf file.tar.bz2:Extracts a file or folder in .tar.bz2 under GNU
  • bunzip file.bz2 | tar -xf -:Extracts a file or folder in .tar.bz2 (all version)



Related FAQ:

Related :

This document entitled « Compression and decompression with the Linux Shell » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.