By default when you unzip a zip file in Ubuntu command line, it extracts everything in the current directory.
This is not pretty. Imagine a zip file with 30 files. All of them will flood your current directory.
This is why, it is a wise idea to extract the zip files to dedicated folder.
You can easily do that in the following manner:
unzip input_zip_file.zip -d path_to_output_folder
You can name the output folder anything you want. Using the same name as the zip file without the .zip extension is the usual behavior when you extract a zip file graphically in Linux, Windows or macOS.
Let's see it in a bit more detail with actual examples.
Extracting zip file to folder
Here's the scenario. I have a zip file in a given folder. I unzip it and it extracts the content into the current directory.
This makes things messy. Which files were there before and which ones are from the zipped file? It isn't easy to distinguish.
Instead, if I extract the zip file to a folder of the same name, things are clean.
unzip output.zip -d output
The output folder could be named anything. It's really up to you. Having the same name as the zip file is the default behavior in GUI.
The output folder can be in any location. Just provide the path to the location where you want to extract the files.
What if the output folder already exists?
Imagine this scenario. You already have a folder with the same name as the destination folder of the unzip command. And this folder already has some files in it.
Can you guess what would happen if you try to extract the zip file to this folder now? Let me show you that.
As you can see, it asks you if you want to replace the existing matching filenames or ignore or rename them. That's the expected behavior.
In this quick tip you learned about extracting zip files to a folder of your choice. This way, your current directory is not messed up with the contents of the zip file. Enjoy it :)