How to Unarchive or Extract files in Linux using Terminal

How to 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 or Compressed Files (Without Extracting)

To list all the files contained in an Archive or Compressed file, 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 or extracting them;

tar -tf tor-browser-linux64_en-US.tar.xz
tar -tvf tor-browser-linux64_en-US.tar.xz

Listing Firefox Browser files without unarchiving or extracting them;

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 doesn’t work make sure you have the xz-utils installed before trying to Unarchive or Extract, by running the following inside Terminal

If you are running 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 or Extracting Tor Browser

tar -xJf tor-browser-linux64_en-US.tar.xz
tar -xJvf tor-browser-linux64_en-US.tar.xz

Unarchiving or Extracting Firefox Browser

tar -xjf firefox-73.0.1.tar.bz2
tar -xjvf firefox-73.0.1.tar.bz2

 

For Unarchiving or Extracting any archive without specifying the format to use to unarchive or Extract, 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 or Extracting Tor Browser

tar -xf tor-browser-linux64_en-US.tar.xz
tar -xvf tor-browser-linux64_en-US.tar.xz

Unarchiving or Extracting 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 extracting capabilities. Make sure to extract the directory inside the archive. To extract, 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.

SUPPORT [[:thetqweb:]] VIA

OR

BUYMEACOFFEE.COM

 

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