Home / Ethical Hacking Tutorials / The ​tar​ Command Cheat Sheet 
Tar.png

The ​tar​ Command Cheat Sheet 

In this post The “tar” Command Cheat Sheet. We will learn how we can use tar command in Linux to deal with “.tar” extension files.

Usage:

tar <OPTIONS> [ARCHIVE NAME] [DIRECTORY OR FILE NAMES]... 
CommandDescription
cUsed to Create an archive
xExtract from an archive 
tList the contents of an archive 
fSpecify a file name for the archive (as opposed to using stdin or stdout) 
vVerbose output (optional, but recommended) 
zUse gzip for compression 
jUse bzip2 for compression 
pPreserve file permissions (active by default for superuser) 

Please keep that thing in mind, you can specify options with or without dashes like (“-zxvf” or “zxvf“) both works as same.

Command Examples

If you want to list files in a qzipped file use this command.

tar -tzf archivename.tar.gz 

If you want to create archive from directory use this command.

tar -cvf archivename.tar directoryname 

Read More: What is Ethical Hacking? How to become an Ethical Hacker

You can extract files from an archive with this command.

tar -xvf archivename.tar 

Command to creating gzipped archive with specific files.

tar -czvf archivename.tar.gz filename1.txt directoryname/filename2.html 

Extract specific files from a bzipped tar archive.

tar -xjvf archivename.tar.bz2 filename1.txt directory/filename2.html

If you enjoyed this article on The “tar” command cheat sheet. Please share this article with your friends on FacebookTwitter

Check Also

Protect-Wi-Fi.png

How to Protect Wi-Fi from Hackers

In this amazing article will we teach you, how you can Protect Wi-Fi from hackers …

One comment

  1. There is noticeably a bundle to know about this. I assume you made certain nice points in features also.

Leave a Reply

Your email address will not be published. Required fields are marked *