How to Extract Zip Files in Linux

Zip files aren’t as common as they used to be when download speeds were slower and every saved byte mattered. Still, it’s a fairly common file type. Sooner or later you’ll probably have to open one.

Depending on the distribution you use, it’s probably fairly easy to extract a zip archive. Even so, it can’t hurt to know some of the more advanced ways you can open zip files and deal with their contents.

Also read: 7-Zip vs WinRAR vs WinZIP: The Best Tool for File Compression

Unzipping Using the GUI

On most Linux desktop environments, unzipping a file is easy. Just right click on the file, and you’ll see a few options. You’ll usually see the option to “Extract Here” or “Unzip Here.”

You’ll also see the option to “Extract To” a location. This is handy if you’re looking to unzip a file from your Downloads folder to somewhere else. Not every desktop environment is going to have these installed, but if they do, it’s the easiest method.

unzip-files-linux-graphical

If your desktop doesn’t include these handy shortcuts, you can just open the zip file in a GUI archive program. This includes Gnome Archive Manager on the Gnome desktop, Ark on the KDE Desktop, and others.

If you don’t have a GUI archive utility available, or you’re looking for more powerful features, it’s time to head to the command line.

Unzipping Files Using the Command Line

While some Linux command-line utilities have arcane names, that isn’t the case here. The command to unzip a file on Linux is simply called unzip.

The simplest way to unzip a file on the Linux command line is to run the following:

unzip filename.zip

unzip-files-linux-command-line

This will unzip the file directly in the directory it is located in. If instead you want to unzip in a different directory, you can do that as well. Imagine that you have a file in your downloads directory that you want to extract in your home directory. To do this, run the following.

unzip filename.zip -d ~/

Previewing Zip File Contents on the Command Line

On the desktop you can often double-click a zip file in order to see its contents before unzipping. Obviously, this isn’t possible on the command line.

unzip-files-linux-list

That doesn’t mean you can’t preview the contents of a zip file. To do this, run the following:

unzip -l filename.zip

The contents of the file will display one line at a time.

Selectively Extracting Parts of a Zip File

Now that you can preview the contents of a zip file, you might realize you don’t need everything in a file. You can approach this in two different ways. You can extract one or two files from a zip archive, or you can choose a file to exclude.

To extract a single file from a zip archive, you’ll need to provide the full path. This means that if there is a folder named Folder that contains everything, you’ll need to specify this.

unzip filename.zip "Folder/file1.txt"

unzip-files-linux-single-file

If you want to extract the file without creating a new directory, use the -j switch:

unzip -j filename.zip "Folder/file1.txt"

Excluding a file works the same way but uses the -x switch. If you wanted to exclude “file.txt,” you would run the following:

unzip filename.zip -x "Folder/file1.txt"

unzip-files-linux-exclude

What About Compressing Files?

Now you know much more about extracting zip files, but that’s only part of the equation. What about when you want to send a few items to a friend or coworker all wrapped up in one file?

Compressing files can be as easy as opening a zip file, but it can also be a bit more complex. If you want to know more, we have a complete guide to compressing and archiving files on Linux.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Kris Wouk

Kris Wouk is a writer, musician, and whatever it's called when someone makes videos for the web.