• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Unix command and scripts » How to create ,List and unzip Tar.gz file in Linux

How to create ,List and unzip Tar.gz file in Linux

June 28, 2020 by techgoeasy Leave a Comment


The GNU tar command included with Linux distributions has integrated compression(.gz) .It can create a .tar archive and then compress it with gzip or bzip2 compression in a single command.  The resulting file is a .tar.gz file or .tar.bz2 file. we will learn about how to create ,List and unzip Tar.gz file in Linux

How to create the tar.gz file

It uses the extra letter z to achieve it

tar -czvf directory.tar.gz <directory Name>
GNU tar cvfz command | unzip Tar.gz file in Linux

How to list tar.gz file

tar -ztvf  <tar gz file>
GNU tar tvfz command

How to compress using bzip2 compression

One more option for compression is  available bzip2, it can be achieved using -j option

tar -cjvf directory.tar.bz2 <directory Name>

How to exclude some files

On some occasion you may wish to compress an entire directory, but not include certain files and directories. You can do so by appending an –exclude switch for each directory or file you want to exclude.

tar -czvf directory.tar.gz <directory Name>  --exclude=*.txt

How to unzip Tar.gz file in Linux

tar -zxvf file.tar.gz

If it is required to extract few files only

tar -zxvf file.tar.gz file1 file2

If it is not possible to use the z option ,  we can use below option to compress the tar files also

tar compress directory command

tar -cvf - dir1 dir2 | compress > file.tar.Z
tar compress directory command

Uncompress will go like

uncompress -c file.tar.Z|tar -xvf  -
tar uncompress directory command

tar gzip command

tar -cvf - file1 file2 | gzip > file.tar.gz
tar gzip command linux

tar guzip command

gunzip -c file.tar.gz|tar -xvf -
tar gunzip command

Related articles 
Linux command for Oracle DBA
sed command in unix examples
basic unix command
loop in shell scripts
awk command in Unix
https://en.wikipedia.org/wiki/Bzip2


Filed Under: Unix command and scripts

Reader Interactions

Leave a Reply Cancel reply

Primary Sidebar

Top Posts & Pages

  • Oracle Indexes and types of indexes in oracle with example
  • Top 30 Most Useful Concurrent Manager Queries
  • Top 46 Oracle ASM Interview Questions
  • Oracle dba interview questions and answers
  • 40 question you must know about R12.2



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • EBS PDB service name disappear from listener in 19c
  • how to download oracle e-business suite 12.2 software
  • Step by step upgrade process to R12.2 Upgrade part -2(Main Upgrade Driver for R12.2.0)
  • Step by step upgrade process for R12.2 Upgrade Part -1
  • Step by step upgrade process for R12.2 Upgrade Part -4(Applying 12.2.x Release Update Pack)

Copyright © 2021 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us