Unzipping files is a common task in Linux. However, it can become a bit tricky when you need to unzip files into a specific folder. In this article, we will explore different methods to unzip files into a specific folder in Linux.
Method 1: Using the unzip command
The unzip command is a built-in utility in Linux that can be used to extract files from zip archives. To unzip a file into a specific folder, you can use the -d flag followed by the path to the target folder.
Here’s the command syntax:
1 | unzip <zip_file_name>.zip -d <target_folder> |
For example, if you want to unzip a file called sample.zip into a folder called “unzipped” in your home directory, you can use the following command:
unzip ~/sample.zip -d ~/unzipped
Method 2: Using the tar command
The tar command is another built-in utility in Linux that can be used to create and extract tar archives. To extract a tar archive into a specific folder, you can use the -C flag followed by the path to the target folder.
Here’s the command syntax:
1 | tar -xvf <tar_file_name>.tar -C <target_folder> |
For example, if you want to extract a file called sample.tar into a folder called “unzipped” in your home directory, you can use the following command:
tar -xvf ~/sample.tar -C ~/unzipped
Method 3: Using GUI tools
If you prefer to use a graphical user interface (GUI), there are many file archiving and extraction tools available in Linux. One popular tool is the file roller, which is the default archive manager for many Linux distributions.
To extract a file using the file roller, you can simply right-click on the zip or tar archive and select “Extract Here” or “Extract to” to specify the target folder.
Conclusion
Unzipping files into a specific folder in Linux is a simple task once you know the right command syntax or have a GUI tool that supports this functionality. The methods discussed in this article should be enough to get you started. However, there are many other options and flags available for the unzip and tar commands that you can explore by reading their respective manuals.