Linux tar Command and How To Tar A Directory

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-tar-command-tutorial-how-to-tar-a-directory/
PINTEREST
PINTEREST
INSTAGRAM

Old days of Unix to make backups into tape archives tar utility was used. The days past and linux become popular in UNIX world. But the popularity of tar is never ended. tar is used compress and extract files. We will look usage examples of tar in this tutorial. Tar command is similar to the Windows zip. We can call this for Linux zip folder. There are alternative ways to compress files but we will look tar linux.

Create Archive with Linux tar

Generally used to make multiple files and directories one file. We will tar a directory

  • for compress but actually it is not compressed
  • for verbosity to see what happens
  • for archive file name
  • dymerge.tar is new tar file name
  • dymerge is the source directory name

Compress While Archiving

We can compress archived with with parameter. is used to gzip format

  • is for gzip compression other options are default for our usage

To compress with bzip2 parameter should be provided.

List Files in Tar Archive

We can list files without opening the tar. parameter is used to list. But if the archive is gzip we should provide too. As we see tar.gz is extension for tarred and gzipped files.

  • list files
  • archive is gzip format
LEARN MORE  How To Get Ram Information In Linux

If the archive is bzip2 we can use following command

Extract Single File From Archive

With tar a single file can be extracted from archive. is the parameter to be used for this operation

  • dymerge.tar.gz is our archive that contains our single file
  • dymerge/surnames.txt is the file we want to extract

Extract Multiple Files From Archive with tar

We can extract multiple files with tar. We need too provide –wildcards parameter and related files for this. Here is used for globing

  • –wildcards is the parameter
  • *.txt is the file names we want to exract

Untar Command

We can create some alias to create new untar command like below.

Adding File into Archive

We can append file into existing archive  with option.

  • We append test.txt file with option
  • We can add directories too
LEARN MORE  How To Create Installation, Live Usb For Linux

Estimate Archive Size

It can be found a archive file size before creation.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-tar-command-tutorial-how-to-tar-a-directory/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)