[Updated on Date: 2021-01-23] As you know, the most popular and widely used compression formats today are zip, tar.gz and rar. Most of the time when you download a file from the Internet, you encounter RAR format. Today we are with you with the tutorial How to extract the file on Linux. In this tutorial, we will compress and extract zip, tar.gz files, as well as how to install the RAR and Unrar command line tools. If you want to buy a Linux VPS server, you can visit the services available in Eldernode.
Tutorial extract the file on Linux
Compression and extraction are one of the most important tasks used in any operating system. If you have used Windows for this, you will notice the ease of work, but in Linux, it is a little different. For example, if you want to extract a compressed file, you can graphically enter the folder or right-click and extract. But there are times when you have no graphical access at all. So you should be able to extract the file or compress the file through the terminal and command.
How to compress and extract a ZIP file in Linux
Follow the steps below to compress in ZIP format on Linux:
– Use the ZIP command and compress with the -r switch, which is to compress all the contents of the folder.
– Then select the name of the new file with its .Zip extension.
– Enter the name of the folder you want to compress at the end of the command.
zip -r NameFile.zip FolderName
The following unzip command is used to extract the zip file:
How to compress and extract tar file in Linux
To compress a .tar folder in Linux, use the tar command with the following switch:
tar -cvf FileName.tar FolderName
The above command is like the zip command and you must first select the desired name with the extension. Then enter the path of the folder you want to compress.
To extract compressed files in tar format, you can also use the following command and enter the file name at the end to be extracted in the same path:
tar -xvf File.tar
How to compress and extract tar.gz files
These files are widely used in servers and control panels. For compression with the tar.gz extension, you can use the following command as in the previous commands:
tar -cvzf FileName.tar.gz FolderName
Enter the following command to extract tar.gz files:
tar -xvf FileName.tar.gz
To open or extract a RAR file, you must first install rar with the following command:
apt-get install rar
Note: This command is suitable for operating systems with Debian kernel. Like Kali Linux and some other hacker operating systems that you can use.
Now you can extract your file by using the e switch and entering the file name and address:
unrar e FileName.rar
Compressing and extracting files is one of the most important tasks used in any operating system, especially the Linux operating system. In this tutorial, we tried to learn you how to compress and extract zip, tar, tar.gz files, and extract RAR files.