How to unarchive/extract files in Linux using Terminal
How to unarchive/extract files in Linux using Terminal

This article shows in details how to unarchive files or how to extract files from archives, in Kali Linux, Ubuntu Linux and other Linux-based systems using Terminal.
Note that:
>> Linux-based operating systems are case-sensitive
>> ‘package‘ represents ‘file name‘
>> ‘*‘ represents ‘extension‘
How to List Archive Files (Without Extracting)
To list all the files contained in an archive, open the directory that contains your archive in Terminal.
To do this, you can right click any empty space within that directory and select the option ‘Open in Terminal’ or just cd (change directory) directly from Terminal.
Then run the following commands;
tar -tf package.tar.*
tar -tvf package.tar.*
-t | show the list of files in the tar file
-f | use archive file (specific)
-v | verbosely list files processed
Practical Examples
Listing Tor Browser files without unarchiving
tar -tf tor-browser-linux64_en-US.tar.xz
tar -tvf tor-browser-linux64_en-US.tar.xz
Listing Firefox Browser files without unarchiving
tar -tf firefox-73.0.1.tar.bz2
tar -tvf firefox-73.0.1.tar.bz2
How to Unarchive or Extract files from Archives
1. bzip2 file (bz2)
tar -xjf package.tar.bz2
2. gzip format (tar.gz)
tar -xzf package.tar.gz
3. txz file (tar.xz)
tar -xJf package.tar.xz
If this doesnt work make sure you have the xz-utils installed before trying to unarchive, by running the following inside Terminal
If you are runing as root;
apt install xz-utils
Non-root users;
sudo apt install xz-utils
If you love watching as the magic happens then add ‘v’ to the 2nd part of the commands, –like:
tar -xjvf package.tar.bz2
tar -xzvf package.tar.gz
tar -xJvf package.tar.xz
Practical Examples
Unarchiving Tor Browser
tar -xJf tor-browser-linux64_en-US.tar.xz
tar -xJvf tor-browser-linux64_en-US.tar.xz
Unarchiving Firefox Browser
tar -xjf firefox-73.0.1.tar.bz2
tar -xjvf firefox-73.0.1.tar.bz2
For unarchiving/extracting any archive without specifying the format to use to unarchive, use the ‘global’ extraction command:
tar -xf package.tar.*
tar -xvf package.tar.*
-x | extract files
-v | verbosely list files processed
-f | use specified archive file
Practical Examples
Unarchiving Tor Browser
tar -xf tor-browser-linux64_en-US.tar.xz
tar -xvf tor-browser-linux64_en-US.tar.xz
Unarchiving Firefox Browser
tar -xf firefox-73.0.1.tar.bz2
tar -xvf firefox-73.0.1.tar.bz2
For all the above examples, the dash ‘-‘ can be omitted. The commands will still work, but it’s best practice to use it, to clearly identify the different sections of the commands.
If you are not the biggest fan of commands, you are also sorted. Just use the inbuilt Archive Manager in Linux operating systems which is quite resourceful in terms of unarchiving capabilities. Make sure to extract the directory inside the archive. To unarchive, open the archive, select the directory/file and click extract.
If you needed to use the extracted directory in Terminal, then open the directory in file manager and right click to an empty space within the directory and click on the ‘Open in Terminal’ option. Terminal should open with the directory as the working directory.
How to Extract/Unarchive files using Terminal in Linux
Hacking | thetqweb