You can compress and decompress files using the terminal or a GUI. In this tutorial I will show you several programs to do this.

Table of Contents

tar

With tar you can compress and decompress files with the “tar”, “tar.gz” and “tar.xz” formats. The difference between “tar” and others is “tar” is not a compress format, but an “archive” (like a folder).

  • Create a tar archive file
    tar -cf <filename>.tar <files>
    
    tar -cf test.tar image.jpg
    tar -cf folder.tar folder/
    
  • Extract a tar file
    tar -xf <filename>.tar
    
  • Create a tar.gz file
    tar -czf <filename>.tar.gz <files>
    
  • Extract a tar.gz file
    tar -xzf <filename>.tar.gz
    
  • Create a tar.xz file
    tar -cJf <filename>.tar.xz <files>
    
  • Extract a tar.xz file
    tar -xJf <filename>.tar.xz
    

More parameters:

  • --one-top-level: when extracting a file, create a folder for extracted files (with the name of the file).

zip

Compress files with the “zip” format.

zip <filename>.zip <files>
# Compress more
zip -9 <filename>.zip <files>

unzip

Decompress “zip” files.

unzip <filename>.zip

Options for unzip:

  • -l: list files in compressed file.
  • -d <folder>: extract files in the specified folder (it will create the folder if it doesn’t exist).

File Roller (GUI)

Default Archive Manager for GNOME (package name is file-roller). File Roller window