Raspberry Pi

How to Extract Files on Raspberry Pi

Many Linux files you download from the internet are in the form of a zip or tar.gz because they are compressed to reduce their sizes to make the data transfer quicker. Although in Windows and macOS, you can extract the contents of the compressed files through different applications like WinRAR, WinZip and so on. However, on a Linux system like Raspberry Pi, you may not be able to use these applications since they are not designed to run on Arm-based systems.

In this article, we will guide you on how you can extract files on the Raspberry Pi terminal.

How to Extract Files on Raspberry Pi From Terminal

The compressed files for Linux-based systems mostly come in zip or tar.gz format. Those who want to install packages may need to extract the files’ contents to perform the packages installed on their Raspberry Pi system successfully. If you have a file in zip or tar.gz format, follow the below-mentioned methods to learn how to extract them from the Raspberry Pi terminal.

Method 1: Extract Zip Files on Raspberry Pi From the Terminal

A zip file includes several files within the folder, which is compressed to reduce the file size. If you have downloaded a zip file on Raspberry Pi and want to extract the file contents, then you can easily unzip it by running the following command in the terminal:

$ unzip [file_name].zip

The Raspberry Pi already includes zip utility, so you don’t need to install it separately.

Suppose we have a file with the name “Finch-master.zip” and to unzip it we are executing the command as follows:

The above command will successfully unzip the contents of the file.

Method 2: Extract tar.gz Files on Raspberry Pi From the Terminal

Most packages’ files are compressed in the form of tar.gz format, which you cannot extract through unzip method. In that scenario, you must use another way to extract their contents so that you can install packages on Raspberry Pi afterward. If you have a file with tar.gz extension, then you can apply the following command to extract the file contents on Raspberry Pi:

$ tar xvzf [file_name].tar.gz

From the above command, “x” defines extracting the archive, “v” display the file contents on the terminal, “z” defines extract the file using gzip while the “f” specifies the name of a tar file.

Conclusion

Extracting the contents of a file on Raspberry Pi is a straightforward task, which you can do easily from your Raspberry Pi terminal. If you have downloaded a “zip” file, you can follow Method 1 for unzipping the file contents on Raspberry Pi. However, if the downloaded file extension is “tar.gz”, you should need to extract this file through Method 2.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.