How to unzip .tgz file using the terminal? [duplicate]
I've downloaded mongodb-linux-x86_64-2.6.3.tgz file using windows 7 and kept it on D:\Amra\Software\Developing Soft location.
When I right click this .tgz file using Ubuntu and see property it shows Location: /media/towhid/Amra/Software/Developing Soft. Now how will I unzip this .tgz file using tar command from terminal?
3 Answers
To extract a .tgz file with tar you need to use,
tar -xvzf /path/to/yourfile.tgzwhere,
xfor extractvfor verbosezfor gnuzipffor file, should come at last just before file name.
You can use the following command in a terminal to unzip the file in your case,
tar -xvzf /media/towhid/Amra/Software/Developing\ Soft/mongodb-linux-x86_64-2.6.3.tgzExtract a .tgz file in different directory:
One can use -C option to extract archive contents to a different directory as following,
tar -xvzf /path/to/yourfile.tgz -C /path/where/to/extract/ 6 Let's end the decades of hardly-memorable one-letter tar options. Use this to extract your .tgz file:
tar --extract --file /path/to/file.tgzThe explanation of used options was purposedly left out.
3Open the terminal and use the cd command to change directories to the directory where the mongodb-linux-x86_64-2.6.3.tgz file is located and the run the following command:
tar xzf mongodb-linux-x86_64-2.6.3.tgz The above command will extract the contents of the mongodb-linux-x86_64-2.6.3.tgz archive while preserving the archive's hierarchical tree directory structure.
A similar command extracts .tar.xz files. Open the terminal and the run the following command:
tar -xf /path/to/your/file.tar.xzExplanation:
-xextract files from an archive-fuse archive file