Compression and decompression with the Linux Shell


Ask a question



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:
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Related