Saturday, December 21, 2024

Dealing With Compressed Files In The Terminal

Extracting Common Compressed Formats on Linux

Extracting Common Compressed Formats on Linux

Incase you only have access to a Terminal here is how you would deal with 10 common compressed files. (like if your on a headless raspberry pi or sshd in from somewhere else)

  1. .tar.gz or .tgz (Gzip compressed tarball):

    tar -xvzf file.tar.gz
  2. .tar.bz2 (Bzip2 compressed tarball):

    tar -xvjf file.tar.bz2
  3. .tar.xz (XZ compressed tarball):

    tar -xvJf file.tar.xz
  4. .zip:

    unzip file.zip
  5. .rar:

    Install unrar first:

    sudo apt install unrar

    Then extract:

    unrar x file.rar
  6. .7z (7-Zip format):

    Install p7zip-full first:

    sudo apt install p7zip-full

    Then extract:

    7z x file.7z
  7. .gz (Single compressed file, not tarball):

    gunzip file.gz
  8. .bz2 (Single compressed file, not tarball):

    bunzip2 file.bz2
  9. .xz (Single compressed file, not tarball):

    unxz file.xz
  10. .Z (Compressed with compress):

    uncompress file.Z

Replace file with the actual name of your compressed file. For .tar formats, the options (-x, -v, -f) can be combined with the respective compression type (z for gzip, j for bzip2, J for xz).

No comments:

Post a Comment