Unzip and uncompress files on a Raspberry Pi
By Russell Barnes. Posted

Advertisement
The desktop computer you've been waiting for: Raspberry Pi 500+
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

Russell runs Raspberry Pi Press, which includes The MagPi, Hello World, HackSpace magazine, and book projects. He’s a massive sci-fi bore.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →

Win one of five Raspberry Pi SSD 1TB
Raspberry Pi prides itself on high quality hardware, and this 1TB Raspberry Pi SSD is no different. You can use it with a standard Raspberry Pi or even in your desktop PC – the choice is yours. We have five to give away and you can enter below Win 1 of 5 Raspberry Pi SSD […]
Read more →

Dual-screen cyberdeck
Twin screens mean you can code on one screen while watching David Bowie’s 1978 Musikladen show on the other.
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.