Ubuntu/Debian — How to Unzip Into a Folder

Ubuntu/Debian — How to Unzip Into a Folder

You may download a ZIP file from the Internet and need to unzip it to a specific directory. On Unix and Linux, you can stay in the command line and unzip a packaged ZIP file to the folder of your choice!

Ubuntu/Debian Series Overview

Unzip Into a Folder

All Linux and Unix systems ship with the unzip command. It’s a command-line utility allowing you to unzip a compressed file.

By default, the unzip command extracts the ZIP’s contents into the current directory. Instead of polluting the current directory with extracted files, you may unzip the files into a new folder using the unzip -d flag:

# “unzip -d” extracts the content into a directory
unzip path/to/file -d path/to/folder

# Example
unzip fonts.zip -d ./new-future-studio-fonts  

Notice: the unzip command won’t create non-existent paths on your disk. If you want to extract the archive into a non-existent folder path, you’ll run into errors.

For example, a directory non-existent-folder does not exist in the current path. If you want to unzip into a subdirectory of this folder, you’ll run into an error.

$ unzip fonts_otf.zip -d ./non-existent-folder/fonts
Archive:  fonts_otf.zip  
checkdir:  cannot create extraction directory: ./non-existent-folder/fonts  
           No such file or directory

That’s it. Unzipping a file from the command line is pretty straightforward using unzip <file> -d <folder>.

Explore the Library

Find interesting tutorials and solutions for your problems.