extract archive – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Wed, 26 Oct 2022 03:29:50 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux https://tecadmin.net/extract-archive-file-linux/ https://tecadmin.net/extract-archive-file-linux/#comments Mon, 05 Jun 2017 18:31:05 +0000 https://tecadmin.net/?p=12830 An archive file is a file composed of one or more files in compressed format. It’s useful for saving disk storage, managing a single file is easier than managing multiple files. This tutorial will help you to decompress or extract an archive file in the Linux system via command line. You can also list archive [...]

The post How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux appeared first on TecAdmin.

]]>
An archive file is a file composed of one or more files in compressed format. It’s useful for saving disk storage, managing a single file is easier than managing multiple files. This tutorial will help you to decompress or extract an archive file in the Linux system via command line. You can also list archive file content without extracting it.

Extract .zip file in Linux

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

Extract .gz file in Linux

Gz files are compressed files created using the Gzip compression utility. In general, GZIP is better 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

Extract .tar file in Linux

Tar is the sort of Tape Archive and also referred to 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

Extract .tar.gz file in Linux

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

Extract .tar.xz file in Linux

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

Extract .tar.bz2 file in Linux

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

Extract .7z file in Linux

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

Extract .rar file in Linux

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 
unrar x filename.rar      # Using Unrar 

Reference:
https://en.wikipedia.org/wiki/Archive_file

The post How To Extract Zip, Gz, Tar, Bz2, 7z, Xz and Rar File in Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/extract-archive-file-linux/feed/ 2
How to Unzip (Extract) GZ File in Linux https://tecadmin.net/extract-gz-file-in-linux-command/ https://tecadmin.net/extract-gz-file-in-linux-command/#comments Tue, 04 Nov 2014 06:50:50 +0000 https://tecadmin.net/?p=6334 A GZ file is a compressed archive that uses the gzip compression algorithm (GNU zip). This format was created to replace compression formats on UNIX systems. It may contain multiple compressed files, directories, and stubs. This compression algorithm is more popular for compressed web pages to reduce page loading time. The GNU zip compressed file [...]

The post How to Unzip (Extract) GZ File in Linux appeared first on TecAdmin.

]]>
A GZ file is a compressed archive that uses the gzip compression algorithm (GNU zip). This format was created to replace compression formats on UNIX systems. It may contain multiple compressed files, directories, and stubs. This compression algorithm is more popular for compressed web pages to reduce page loading time.

The GNU zip compressed file uses .gz or .z extension. In this article, you will learn how to decompress (Unzip or extract) a GZ file via the command line.

Extracting GZ file:

We can use gunzip command to decompress a .gz file on Linux and macOS systems.

gunzip file_name.gz 

A .gz file is compressed with gzip command line. That can also be used to decompress it with -d parameter.

gzip -d file_name.gz 

Both the above commands retrieve back the original file and remove the .gz extension from file name.

Once you have decompressed a .gz file, it will no longer avaialble. But, if you want to keep the archive file use -k or --keep option with unzip command.

gzip -d -k file_name.gz          ## OR
gunzip -k file_name.gz 

Example

  • First, use the following command to create gzip (.gz) archive of the access.log file. Keep remembering that the below command will remove the original file.
    gzip access.log 
    
  • Above command will create a archive file named access.log.gz in current directory.
    ls -l access.log.gz 
    
    -rw-r--r-- 1 root root 37 Sep 14 04:02 access.log.gz
    
  • Now use gunzip command to extract the access.log.gz file using the command. This will extract the file from the archive and remove the .gz file automatically.
    gunzip access.log.gz 
    

Conclusion

In this blog post, you have learned about extracting a .gz on Linux or macOS system using command line. You can also enable Gzip compression in Apache.

The post How to Unzip (Extract) GZ File in Linux appeared first on TecAdmin.

]]>
https://tecadmin.net/extract-gz-file-in-linux-command/feed/ 4
Linux tar Command with Useful Practical Examples https://tecadmin.net/linux-tar-command-with-useful-practical-examples/ https://tecadmin.net/linux-tar-command-with-useful-practical-examples/#respond Tue, 16 Apr 2013 06:59:51 +0000 https://tecadmin.net/?p=872 GNU TAR (Tape ARchive) combines multiple files together into a single tape or disk archive, and can restore individual files from the archive. Here are some Linux tar command with Useful practical examples. Some useful command line switches are given below, which are used in this article. -c => create a new archive file -v [...]

The post Linux tar Command with Useful Practical Examples appeared first on TecAdmin.

]]>
GNU TAR (Tape ARchive) combines multiple files together into a single tape or disk archive, and can restore individual files from the archive. Here are some Linux tar command with Useful practical examples.

Some useful command line switches are given below, which are used in this article.

  • -c => create a new archive file
  • -v => show the detailed output (or progress) of command
  • -x => extract an archive file
  • -f => specify file name of an archive
  • -z => Use archive through gzip
  • -j => Use archive through bzip2
  • -J => Use archive through xz
  • -t => viewing content of archive
  • -O => Display file content on stdout
  • -r => append file to existing archive
  • -C => Use of define destination directory
  • -W => Verify a archive file

How to Create Archive using Tar

Use the following examples to create new archive file in different formats like .tar (a simple archive file), .tar.gz (gzip archive), .tar.bz2 (bzip2 archive file), and .tar.xz (xz archive file).

1. Create .tar archive file – Compress all content of /var/www directory to a archive.tar file including all subdirectories.

tar -cvf archive.tar /var/www

2. Create .tar.gz archive file – Compress all content of /var/www directory to a archive.tar.gz file including all subdirectories. This will create higher compressed file that above.

tar -zcvf archive.tar.gz /var/www

3. Create .tar.bz2 archive file – Compress all content of /var/www directory to a archive.tar.bz2 file including all subdirectories. This takes more time to compress than others and provides the highest compressed file that above.

tar -jcvf archive.tar.gz /var/www

4. Create .tar.xz archive file – Compress all content of /var/www directory to a archive.tar.xz file including all subdirectories. This takes more time to compress than others and provides the highest compressed file that above.

tar -Jcvf archive.tar.xz /var/www

How to Extract Archive using Tar

Use the following commands example to extract archive files. In this section each example has two commands, the First command will extract content in the current directory and the second command will extract file content in the specified directory with -C option.

5. Extract .tar archive file –

tar -xvf archive.tar
tar -xvf archive.tar -C /tmp/

6. Extract .tar.gz archive file –

tar -zxvf archive.tar.gz
tar -zxvf archive.tar.gz -C /tmp/

7. Extract .tar.bz2 archive file –

tar -jxvf archive.tar.bz2
tar -jxvf archive.tar.bz2 -C /tmp/

8. Extract .tar.xz archive file –

tar -Jxvf archive.tar.xz
tar -Jxvf archive.tar.xz -C /tmp/

How to List Archive File Content with Tar

You can list all the content inside a tar (Tape ARchive) file without extracting it. It helps the user to check available files in an archive and save users time.

9. List .tar archive file content –

tar -tvf archive.tar

10. List .tar.gz archive file content-

tar ztvf archive.tar.gz

11. List .tar.bz2 archive file content-

tar jtvf archive.tar.bz2

12. List .tar.xz archive file content-

tar Jtvf archive.tar.xz

How to Update Tar Archive File

You can use -u option to simply update archive file. Using this option, it will only append files newer than the copy in the archive file.

13. Update .tar archive file –

tar -uvf archive.tar /var/www

14. Update .tar.gz archive file –

tar -zuvf archive.tar.gz /var/www

15. Update .tar.bz2 archive file –

tar -juvf archive.tar.bz2 /var/www

16. Update .tar.xz archive file –

tar -Juvf archive.tar.xz /var/www

Other Useful Archive File Commands

Below are some more useful options available for handling tape archive files. Below examples are shown in the simple .tar file. You can use them with .tar.gz (-z option), .tar.bz2 (-j option) and .tar.xzf (-J option).

17. Display file content – use -O followed by filename, this will display content of specified file.

tar -uvf archive.tar -O backup/index.html

18. Adding file to archive – use -r followed by filename to add more files to existing archive file.

tar -rvf archive.tar add_new_file.txt

Conclusion

In this tutorial you have learned about Linux tar command with useful practical examples.

For more details, visit: http://www.gnu.org/software/tar/manual/tar.html

The post Linux tar Command with Useful Practical Examples appeared first on TecAdmin.

]]>
https://tecadmin.net/linux-tar-command-with-useful-practical-examples/feed/ 0