Unzip and uncompress files on a Raspberry Pi

By Russell Barnes. Posted

Files downloaded from the internet almost always arrive on your computer as compressed files. In this feature we're going to look at how to unzip (or uncompress) files on a Raspberry Pi.

Files are often compressed before being made available for transfer. The reduced file sizes are quicker to download, smaller to host, and save money on bandwidth.

Pretty much everybody is familiar with the concept of a compressed file, often called a ‘zipped’ file thanks to the early, and still popular, zip format.

Unzip files on a Raspberry Pi

Uncompressing, or ‘unzipping’ a compressed file isn’t a complicated task, but there is a baffling array of different compression techniques and files, each requiring its own tool and technique for restoring the file to its former glory.

Lets look at the different compressed file types you’ll come across when using a Raspberry Pi, and how to go about unzipping them.

STEP-01: Archiver

Your first stop for uncompressing any file on your Raspberry Pi should be to use Archiver. This lightweight desktop app, also known as Xarchiver, is included with Raspbian and can handle 7-zip, arj, bzip2, gzip, rar, lha, lzma, lzop, deb, rpm, tar, and zip archives. Open it using Menu > Accessories > Archiver.

STEP-02: Open archived files

Choose Archiver > Open or click on the ‘Open an Archive’ icon. Choose a compressed file (typically it’ll be saved in your Downloads folder) and click Open. It may take a while to scan the file, depending on its size. We’re using the RISC OS image from here as a test.

STEP-03: Select and view

Typically, you’ll want to extract all the files in a compressed image, but it’s worth knowing that you can select individual files and extract them. You can also double-click on files in the compressed image inside Archiver to view them (handy for ReadMe files).

STEP-04: Extract

The Extract Files window is straightforward. If all you want are the files, then click Extract and they’ll be saved into the same location (typically Downloads). You can change the Extract To folder, but you won’t have sudo privileges, so stick to directories inside /home/pi/. You can also enter the password to access restricted compressed files. The icon in the bottom-right corner of Archiver will flash green and red while it extracts the files, and solid green when it’s done.

Unzip, extract and uncompress files in Terminal

You may need to extract files while working from the command line. There’s a range of tools you’ll need – some are installed on the Raspberry Pi and others you’ll need to acquire with apt-get. Here are the commands you need for many popular extension types. Enter man and the file type, such as man tar, to view more information.

  • File extension: .tar tar xvf filename.tar
  • File extensions: .tar.gz, .tgz, .tar.bz tar xzvf filename.tar.gz
  • File extension: .gz gunzip filename.gz
  • File extensions: .bz, .bz2 bunzip2 filename.bz2
  • File extension: .xz unlzma filename.xz
  • File extension: .zip unzip filename.zip
  • File extension: .7z sudo apt-get install p7zip-full 7z x filename.7z
  • File extension: .rar sudo apt-get install unrar-free unrar x filename.rar

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.