To unzip a file to a specific location in Linux, you can use the unzip
command with the -d
option followed by the target directory. Here’s how you can do it:
- Open the terminal on your Linux system.
- Navigate to the directory where the ZIP file is located using the
cd
command. For example, if your ZIP file is in the Downloads folder, you can use the following command:
Example Bash Navigation Command
cd Downloads |
- Once you are in the correct directory, you can use the
unzip
command followed by the name of the ZIP file and the-d
option with the target directory. For example, if your ZIP file is named “example.zip” and you want to extract it to a folder named “myfolder” located in your home directory, the command would be:
Example Unzip Command
unzip example.zip -d ~/myfolder |
The ~
represents your home directory, so ~/myfolder
specifies the target directory path relative to your home directory.You can also provide an absolute path instead of a relative one if you know the exact location where you want to extract the files.Ensure that the target directory exists before running the command. If it doesn’t exist, you can create it using the mkdir
command.
After running the unzip
command, the files and folders from the ZIP archive will be extracted to the specified location.