Linux Tutorials
About Lesson

Tar Command:

The tar command stands for tape achieve, which is the most commonly used tape drive backup command used by the Linux/Unix system. It allows for you to quickly access a collection of files and placed them into a highly compressed archive file commonly called tarball, or tar, gzip, and bzip in Linux.

Common Options –
-c –create Create a new archive.
-x –extract Extract files from an archive.
-t –list List the contents of an archive.
-f –file=ARCHIVE Use archive file or dir ARCHIVE.
-v –verbose Verbosely list files processed.
Compression Options –
-a –auto-compress Use archive suffix to determine the compression program.
-j –bzip2 Filter the archive through bzip2.
-J –xz –lzma Filter the archive through xz.
-z –gzip Filter the archive through gzip.

Compress a folder

This creates a simple archive of a folder :

tar -cf ./my-archive.tar ./my-folder/

Verbose output shows which files and directories are added to the archive, use the -v option:

tar -cvf ./my-archive.tar ./my-folder/

For archiving a folder compressed ‘gzip’, you have to use the -z option :

tar -czf ./my-archive.tar.gz ./my-folder/

You can instead compress the archive with ‘bzip2’, by using the -j option:

tar -cjf ./my-archive.tar.bz2 ./my-folder/

Or compress with ‘xz’, by using the -J option:

tar -cJf ./my-archive.tar.xz ./my-folder/

Extract a folder from an archive

There is an example for extract a folder from an archive in the current location :

tar -xf archive-name.tar

If you want to extract a folder from an archive to a specfic destination :

tar -xf archive-name.tar -C ./directory/destination

Let’s Join our Hacking Team

We Are Indian We Are Great

Hope this article helpful for you. Thank You

Indian Cyber Army | Make IT Secure

Enjoy…Stay Happy…Stay Secure…

Hope this article helpful for you. Thank You


If You Appreciate What We Do Here On Hackonology, You Should Consider:

Hackonology is the fastest growing and most trusted community site where you can find lots of courses, articles about Technology/Hacking/Cracking. Millions of people visit Hackonology! to search or browse the thousands of published articles available FREELY to all.

Let's be a part of Hacker's Community! Join our Hacking Team

We Are Indian We Are Great


Exercise Files
No Attachment Found
No Attachment Found