Debian

How to Unzip Files in Debian 12

How to Unzip Files in Debian 12

A ZIP or Compressed file is a popular archive file format that combines multiple files into a single file. The most commonly used archive types are .zip,.rar, and .tar.gz. They can be useful for conserving system space and sending the data at more speed. Since it is a ZIP file, it can be smaller, making it easier to download. Linux provides various ways to zip and unzip numerous files and directories. The ZIP is a famous command line utility of Linux that is used to store multiple files into a single .zip format. Other than that you can also use archive (tar) to compress and unzip files in Debian.

Extracting files from a compressed folder allows you to properly view and run the files on your system. Once you have downloaded the ZIP file on your device, it is easy to unzip the file to view the content.

Quick Outline

 

How to Unzip Files in Debian 12

Below we have listed the two approaches to unzip files in Debian:

 

Method 1: How to Unzip Files in Debian 12 Through GUI

The most convenient and straightforward method to unzip a file in Debian 12 is through the GUI, it can be done from the following step-by-step guidelines:

Step 1: Navigate to Activities and search for Files:

Step 2: Next, switch to the directory where the zip file is stored. In my scenario, I have stored the zip file in Downloads with the name Sampelfiles.zip:

Step 3: Right-click on the zip file, and choose one of the following highlighted options:

1: Extract: If you choose Extract, it will unzip a file into a current directory immediately.

2: Extract to..: If you choose Extract to, it will ask you to select your desired folder to unzip a file. When you select Extract to.., a prompt will appear on your screen to choose the exact destination for extracting the files. You can either choose an already existing folder or create a new folder by clicking on the create folder icon:

Enter the name of the folder and click on Create:

Step 4: Next, select the created folder and click on Select:

It will unzip a folder into a chosen directory. When you unzip a file, a new folder of the same name will be created which contains the files:

 

Method 2: How to Unzip Files in Debian 12 Through CLI

Another way is to use the command line interface (CLI) to unzip files on Debian 12, for this purpose, there are two powerful commands:

 

How to Unzip Files in Debian 12 Through CLI Using unzip Command

The unzip is a command line utility that is used to extract files through a zip archive. It comes preinstalled on most of the Debian systems. You can check the version of the unzip on Debian to verify its installation through the below-given command:

unzip --version

If the command shows the version then it is already installed on your system. Otherwise, you can execute the following command to install the unzip utility on Debian:

sudo apt install unzip

The unzip command has many functions that can be used to manage zip archives. Run the following command to learn different options of the unzip command:

man unzip

Now, we will discuss the options used with the unzip command in Debian 12 to unzip files, like we use the unzip command to:

 

1: Test the Validity of Zip Archive File

Execute the unzip command with the -tq option to check the validity of the file before unzipping it:

unzip -tq Samplefiles.zip

 

2: View the Content of Zip File

We can use the -l option to display all the files stored in the zip file:

unzip -l Samplefiles.zip

 

3: Unzip Files into a Current Directory

To unzip files into a current directory on Debian, first switch to the directory where the zip file is located. The general syntax to unzip a file into a current directory using an unzip command is written below:

unzip <file_name>

Example: I have a Sampelfiles.zip file located in the Downloads directory and I want to unzip the file into the same directory:

unzip Samplefiles.zip

 

4: Extract Multiple Files

You can unzip all the zip files in any directory on Debian using the following command:

unzip '*.zip'

 

5: Unzip Files into a Different Directory

You can also unzip files into a different directory on Debian by using the -d option and provide the path of the directory either full or relative:

unzip <File_name> -d <destination_file>

Example: I have samplefile.zip and I want to unzip it into a different directory named as Files:

unzip Samplefiles.zip -d Files

Else, you can also provide the full path of the zip file and destination file as mentioned in the below syntax command:

unzip /path_to_zip_file -d /path_to_destination_directory

 

6: Unzip Files Except for Few Files

You can use the -x option with the unzip command on Debian to ignore a few files while performing the unzip command. For example, if I want to unzip Samplefiles.zip but want to ignore the myfile4.txt, then you can run the following command. The myfile4.txt will not be included in an unzip file of Sampelfiles.zip:

unzip Samplefiles.zip -x myfile4.txt

 

How to Unzip Files in Debian 12 Through CLI Using tar Command

The other command line utility to create and extract compressed files on Debian is tar. It comes preinstalled on almost every Linux distribution and is ready to use whenever you need it. If you use the tar utility to zip the file, the file format will be .tar.gz and you can also use this utility to retrieve the files from the archive file.

 

You can use tar command in Debian 12 to:

 

1: How to List the Content of tar File in Debian 12

Before extracting a file, it is a good idea to view the content of the file. You can execute the below command to list all the files stored inside the tar archive:

tar -tf <file_name>

Here:

t: Displays the list of all files present inside the archive file.

f: It identifies the name of the archive file

Example: In the following command, I have displayed the content of the Sample.tar.gz file:

tar -tf Sample.tar.gz

 

2: How to Extract tar Files in Debian 12

The following is the basic syntax to extract the tar archive file into a current directory:

tar -xvf <file_name>

Here:

x: Extracts the archive files.

v: Print any verbose operation of the tar file.

f: Specifies the file name of the tar file.

Example: In the following example, I am using the tar command to extract the content of the sample.tar.gz file:

tar -xvf Sample.tar.gz

 

3: How to Extract tar Files into a Different Directory on Debian 12

Run the tar command in Debian as follows if you want to extract the archive file into another other directory:

tar -xvf <file_name> -C <directory_name>

The directory where you are extracting the content of the tar file must exist before executing the command.

Example: I have extracted the Sample.tar.gz into a File directory by running the following command:

tar -xvf Sample.tar.gz -C Files

 

4: How to Extract Only Few tar Files on Debian 12

The tar command also allows you to extract specific files from a tar file. In the below command, I have extracted the myfile1.txt and myfile2.txt from the Sample.tar.gz file:

tar -xvf Sample.tar.gz myfile1.txt myfile2.txt

If you want to view the other available options with the tar command, open manual by executing the following command:

man tar

 

Conclusion

An archive or compressed file is an efficient way to store and transfer data. It helps to reduce size as they are frequently attached in emails. If you ever receive a compressed file on your Debian system, you can extract its content to view it properly using the GUI or CLI. In the command line, we have mentioned the two command line utilities in this post. One is unzip, which is a powerful utility to test, list, and extract the content of the .zip file. The other is the tar command that is used to extract and preview the content of the .tar.gz file. You can use the range of options to control these utilities on your Debian and unzip files on your system.

Similar Posts