How to unarchive/extract files in Linux using Terminal

How to unarchive/extract files in Linux using Terminal

Linux Unarchiving
Unarchiving in Linux

 

 

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
>> ‘*representsextension

 

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 ommited. 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.

 

You should be careful with Commands. They are very easy, fast and fun to use but they can also cause great damage fast! Follow thetqweb’s Hacq Linux Series to ENJOY USING LINUX!

 

Consider buying thetqweb.com a coffee [buymeacoffee.com/thetqweb.com] if this information was helpful. Even the least is most significant! This site is supported by generous donations such as yours! Click on the floating Purple Coffee Cup on the bottom-right side, or click on the “Buy me a Coffee” tab on the site! Thank You in Advance!

How to Extract/Unarchive files using Terminal in Linux
Hacking | thetqweb