Be Informed And Earn: 2 Methods of How To Easily Compress And Extract Files in Linux Withiout Any Software

Monday, May 29, 2017

2 Methods of How To Easily Compress And Extract Files in Linux Withiout Any Software

One of the first things I tried doing on Kali Linux was to enable boot sound, get a download manager and a utility archive manager. I pulled up a google search on how to get any of these done, but all the tutorials I could find were all sounding like a rocket science to me. Luckily for me, I got installation part of it done, by using Wine Application plus several other tutorials I could lay my hands on. But getting a file compressed or decompressed proved to be a problem until I got a method that worked for me smoothly. So if you've been looking for a way to compress or decompress file(s) in Linux, just read on.
In Windows, archived files are traditionally ended with either .rar or .zip extension. But in Linux, we will be talking about gzip, and gunzip commands as well as their associated options. These commands come with a simple syntax which makes your compressing and decompressing task easier. We shall take them one after the other, then make a little explanation of what they are as well as the work they do. But before we proceed, it is imperative to note that there are several archiving software in Linux, so in case this method didn't work for you because of one reason or the other, you can go right ahead and download any other one of your choice.

This is How Easily Compress and Extract Files in Linux:

Tar Command:
This command is used to make several files and folders to become one. The tar command to extract or list the contents of a tar archive. depending on what the case might be. Below is the command for using the tar command to archive and compress files:

tar [-] c|x|t f tarfile [pattern]

Some of the most common options used together with the tar command include:

1.    x – Extract files from the archive
2.    c – Create a tar archive
3.    v – Verbose
4.    t – Display the table of contents (list)
5.    f – to specify the file to compress or extract
6.    z – Use compression
I guess a little expression will do just fine and is appropriate.

Let's take for instance I have a folder on my Linux PC Desktop that I've named Techvillz Archive, and I want to make a tar archive of it. Here is how to get it done. I will open my Linux command terminal and type the following commands:

root@techvillz :~/Desktop$ ls Techvillz Archive/
Archtve.txt Compress.txt
root@techvillz :~/Desktop$ tar cf tv.tar Techvillz Archive
root@techvillz :~/Desktop$ tar tf tv.tar
Techvillz Archive/
Techvillz Archive/Compress.txt
Techvillz Archive/Archtve .txt

For more understanding, what I have just done is to apply the above c, f and t options in the command and made an archive. The c is used to create the file, f” to specify the file to archive, while the tv.taris archive file itself.

Now let us try to decompress and extract the contents of the same archive file we just created. For easier and quick access, we'll use Desktop as our storage path and will do this:

root@techvillz :~$ cd Desktop/
root@techvillz :~/Desktop$ tar xf /home/techvillz/tv.tar
root@techvillz :~/Desktop$ ls -l Techvillz Archive/
total 0
-rw-rw-r- - 1 techvillz techvillz 0 May 24 11:17 Archive.txt
-rw-rw-r- - 1 techvillz techvillz 0 May 24 11:17 Compress.txt

In the above command. you will notice x which is used to extract files from the archive and also the f option which is used to select the file we wish to extract. Please note that 0 in the command line is zero and not letter O.

The Gzip and Gunzip Command

The next in our tutorial on how to compress and extract files in Linux is by the use of Gzip and Gunzip commands. Gzip is used to compress and create an archive file. While the GunZip is used to do the opposite. To get this done, we follow these simple steps and type the following commands, and the name of the archive file we wish to compress or decompress is techvillz official.

gzip/gunzip techvillz official

root@techvillz:~ $ du -k echvillz official
8        techvillz official
root@techvillz:~ $ gzip techvillz official
root@techvillz:~ $ ls techvillz official*
techvillz official:~ $ techvillz official.gz   techvillz    techvillz
techvillz official:~ $ du -k techvillz official.gz

4          techvillz official.gz

And for the decompressing, we use the following commands

root@techvillz:~ $ du -k techvillz official.gz
techvillz official.gz
root@techvillz:~ $ gunzip techvillz official.gz
root@techvillz:~ $ du -k techvillz official.gz
techvillz official.gz

This is how to compress a file(s) and folders in Linux using the command terminal. if there are any issue and hiccups, fell free to share and ask.

If You Enjoyed this Post, Kindly take 5 Seconds and Share it With Your Friends on

No comments:

Post a Comment

***We ❤ to hear from you, Tell us Your views and opinion. Please note that comments are always moderated, Abusive comments won't be approved, and spammy comments are deleted automatically