How To Unzip File Linux

Unzip File Linux

Welcome to the world of Linux! It’s like a super-smart computer system that many tech fans love. One cool thing about Linux is that you can make big files smaller to save space and share them easily. In this guide, we’ll learn how to open up these small files again. Imagine it like opening a present to see what’s inside! Whether you’re new to Linux or already know a bunch, this guide will teach you easy ways to do this. So, get ready to learn how to unzip files in Linux!

Unzip Syntax

First of all, you need to install the unzip package. To do so, type in a terminal command:

sudo apt-get install unzip

Once all the packets have been installed, to unzip the archive files type in a terminal command:

unzip archive.zip

A more useful tool is 7z, which zips and unzips a range of compression formats, notably lzma, usually the protocol offering the highest compression rates.

sudo apt-get install p7zip-full

Extract the zip file with Linux

  1. Open the Files App: Just like opening a folder on your computer, open the Files app on Linux.
  2. Find the Zip File: Look for the folder where the zip file is saved. It’s like finding your special file.
  3. Click with the Right Mouse Button: Put your mouse pointer on the file you want to open. Then, press the right mouse button (the one on the right side).
  4. Menu Appears: Imagine a small menu popping up. It gives you choices.
  5. Choose What You Want: Click on “Extract Here” if you want to open the zip file in the same place. Or, choose “Extract to…” if you want it to open in a different spot.

Unzip arguments in Linux

  1. file[.zip]: This shows the path of the zip file you want to work with. It’s like telling the computer where the special file is. You can’t use wildcards in the path, only in the filename itself.
  2. [file(s)]: You can list the files inside the zip that you want to do something with. These are like the parts of the special file you’re interested in. You can put the names of these files separated by spaces. If you’re using an older version of this, you might need to separate the files with commas.
  3. [-x file (s)]: This part helps you exclude specific files from what you’re doing. Imagine you have a bunch of things in your special file, and you only want to work with some of them. You can use this to tell the computer what to skip.
  4. Exclude List: You can make a list of things you don’t want to deal with. If there are files in special folders, you can tell the computer to not look at them. This is because some special symbols might match folder names too, and this helps you avoid that (with some exceptions).
  5. -d Destination Directory: If you say “-d” and then the name of a place, the computer will put the things it unzips there. Normally, things get unpacked in the same place, but this lets you choose a new spot. You can put this instruction before or after other instructions.

Unzip Commands/Options in Linux

1. Unzip a file to a different directory

To unzip a file in a different spot, use the -D option. Click the zip file in your file manager, then open the terminal. Type:

unzip -D filename.zip

Replace “filename.zip” with your zip file’s name.

Command: $ unzip filename.zip -d /path/to/directory

2. Unzip tar/tar.gz/tgz files to a specific directory

In Linux, many files are packed using the “tar” format. A “.tar” file is a group of uncompressed files, often called a tarball. Unlike “.tar,” it doesn’t compress things; for that, another tool is needed. The “tar” command can both create and unpack tar archives. This trick also works with different file types.

A “tar.gz” file is a mix of “.tar” and “.gz” (gzip) files. When you use the tar command, it unpacks the files into your current spot. Here’s how in the terminal:

Command:

tar -xf file-name.tar -C /path/to/directory

3. Unzip a password-protected zip file

To unzip a file that is password-protected, we have to invoke the unzip command with the -P option i.e -P (Password) Option followed by the password:

Command: $ unzip -P PasswOrd filename.zip

4. Exclude Files when Unzipping a ZIP File

To exclude specific files or directories from being extracted, use the -X (Exclude) option in the terminal :

Command: $ unzip filename.zip -x file1-to-exclude file2-to-exclude

5. Suppress the Output of the unzip Command

“unzip” shows what it’s doing. To make it quiet and not talk too much, use “-q”.

Command: $ unzip -q filename.zip

6. Overwrite existing files

To replace files without asking, use the -o option. In the terminal, type:

unzip -o filename.zip

7. Unzip a zip file without overwriting existing files

You can use the -n option to make “unzip” skip files that are already there:

unzip -n filename.zip

8. List the Contents of a zip file

To see what’s inside a zip file, use the -l (list archive) option. In the Windows terminal, type:

unzip -l filename.zip

FAQ – How To Unzip File Linux

Q1. How do I unzip and read a file in Linux?

Ans. To unzip files, follow the steps from the “Zipping Files via GUI” section. Open the File Manager and locate the ZIP file you want to unzip. Right-click on the ZIP package and choose “Extract Here.” Linux will then extract all the files from the ZIP package right where you are.

Q2. What is the MV command in Linux?

Ans. The “mv” command does two main things: it shifts files or folders between places, and it can also change a file or folder’s name. If you move something to a new spot, its name stays the same. If you move it, any connections to other files stay, unless you move it to a different file system.

Q3. How do I read a file in a Linux shell?

Ans.Passing the filename from the Command line and reading the File
#!/bin/bash.
file=$1.
while read line; do.
#Readind each line in sequence.
echo $line.
done <read_file.txt.

Hridhya Manoj

Hello, I’m Hridhya Manoj. I’m passionate about technology and its ever-evolving landscape. With a deep love for writing and a curious mind, I enjoy translating complex concepts into understandable, engaging content. Let’s explore the world of tech together

Leave a Comment