Flipkart

Wednesday, February 20, 2019

How to Open, Extract and Create Zip, Gz, Tar, Bz2, 7z, Xz and Rar Files in Linux

How to Extract .zip File:

This is the most common compression format used by various IT professions on many operating systems. For this you must of unzip binary installed on your system.

$ unzip filename.zip

How to Create Zip Excluding Specific Files & Directories

How to Extract .gz File:

Gz files are compressed files created using the Gzip compression utility. In general, GZIP is better in compared to ZIP, in terms of compression, especially when compressing a huge number of files. Use gunzip command to extract .gz archive file.

$ gunzip filename.gz

How to Extract .tar File:

Tar is the sort of Tape Archive and also referred as the tarball. This is another popular archiving method which is also known as the consolidated Unix archive format. To extract .tar file use following command

$ tar -xvf filename.tar

How to Create Tar Excluding Specific Files & Directories

How to Extract .tar.gz File:

TAR.GZ file is a combination of TAR and GZIP archives. If provides more compression format of data. You can use -z switch to extract these files.

$ tar -xzf filename.tar.gz

How to Extract .tar.xz File:

The XZ format is a single file compression format and does not offer archiving capabilities. It preserves the original data with no loss in quality. You can use -J switch to extract these files.

$ tar -xJf filename.tar.xz

How to Extract .tar.bz2 File:

Tar.bz2 is an combination of tar and bzip2 archive formats. You can use -j to filter the archive through bzip2. Use the following to extract .tar.bz2 compressed file.

$ tar -xjf filename.tar.bz2

The latest version fo tar automatically detects the archive format. So you can simply use the following command.

$ tar -xf filename.tar.gz

How to Extract .7z File:

These files are 7zip archive files. This is not generally used on Linux systems, but sometimes you may need to extract some source files. You must have the 7zip package installed on your system. Use the following command to extract these files.

$ 7z x filename.7z

How to Extract .rar File:

These are common archive format for Windows systems, but Linux users avoid to use this. Still you may need sometimes to extract .rar file on Linux. You can use 7z command to extract this or unrar.

$ 7z x filename.rar # Using 7zip

Install RAR tool

If you are using Redhat Linux or Centos, then use yum command as follows to install unRAR command.

#yum install unrar

The unRAR command supports various options, below are common options that you need to for extracting files. Listed below are few examples of RAR and unRAR command.

1. RAR a single file

#rar a log-cups.rar /var/log/log-cups

RAR 3.90 beta 2 Copyright (c) 1993-2009

Alexander Roshal 3 Jun 2009

Shareware version Type RAR -? for help

Evaluation copy. Please register.

Creating archive syslog.rar

Adding /var/log/syslog OK

Done

2. RAR multiple files

Compress ‘file1′, ‘file2′ and ‘file3′ simultaneously,

#rar a file1.rar file1 file2 file3

You can also use the following method to RAR multiple files.

#rar a -r file1.rar file1 file2 file3

3. unRAR compressed file

#unrar e file1.rar

4. List the content of a RAR file without extracting the file

#unrar l file1.rar

5. Extract files with full path

#unrar x file1.rar

6. Check the integrity of archive file

#unrar t file1.rar

7. Create a password protected RAR file

While archiving, you can encrypt files with the password (using -p option). If you omit the password on the command line, you will be prompted with message “enter password” and password is case sensitive.

#rar a -pQAZWSX backup '*.txt'

No comments:

Post a Comment