Friday, January 22, 2021

How to tar a file in linux

Let say u have a directory under /rajesh/logs/ and logs has multiple logs and trace files, and you would like to create or tar the logs files means execute the command below as

tar -zcvf tar_filename.tar.gz /rajesh/logs

In your current directory the file will be created

  • -c : Create a tar ball.
  • -v : Verbose output (show progress).
  • -f : Output tar ball archive file name.
  • -x : Extract all files from archive.tar.
  • -t : Display the contents (file list) of an archive.

Create a tar ball called /tmp/data.tar for /home/vivek/data directory, enter:
tar -cvf /tmp/data.tar /home/vivek/data

To View a Tar Ball Contains (list file inside a tar ball)

Type the following command:
tar -tvf /tmp/data.ta

To Extract a Tar Ball

Type the following command to extract /tmp/data.tar in a current directory, enter:
tar -xvf /tmp/data.ta
Type the following command to extract resume.pdf file from an archive called data-backup.tar in a current directory, enter:
tar -xvf data-backup.tar resume.pdf
Type the following command to extract pic1.jpg, file1.doc, and foo.mov files from an archive called data-backup.tar in a current directory, enter:
tar -xvf data-backup.tar pic1.jpg file1.doc foo.movf
Type the following command to extract /tmp/data.tar in a directory called /home/sales/data, enter:
tar -xvf /tmp/data.tar -C /home/sales/data

No comments:

Post a Comment

How to Trouble shoot Logfile_sync wait event

   First  Identify and break down LGWR wait events. Query wait events for LGWR. In this instance LGWR sid is 3 (and usually it is). select s...