Linux and Unix TAR Command

Linux and Unix TAR Command

In this tutorial, we will show you various Linux and Unix Tar command examples that might be helping you. For those of you who didn’t know, The tar command is used to rip a collection of files and directories into highly compressed archive files commonly called tarball or tar, gzip and bzip in Linux. The tar is the most widely used command to create compressed archive files and that can be moved easily from one disk to another disk or machine to machine. The main purpose of this article is to provide various tar command examples that might be helping you to understand and become an expert in tar archive manipulation.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. If you want to learn about tar commands in Linux with Examples then this post is ideal for you.


  • A server running one of the following operating systems: Ubuntu-based or RHEL-based.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo useror access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Linux and Unix TAR Command

  • Create tar Archive File

Example command creates a tar archive file idroot.tar for a directory /home/idroot in the current working directory.

$ tar -cvf idroot.tar /home/idroot/

  • Create tar.gz Archive File

Example command creates a compressed gzip archive file idroot.tar for a directory /home/idroot in the current working directory.

$ tar cvzf Mythemes.tar.gz /home/idroot

  • Untar a tar File or gzip-bz2 tar File
$ tar xvzf idroot.gz - for uncompress a gzip tar file (.tgz or .tar.gz)
$ tar xvjf idroot.tar.bz2 - for uncompress a bzip2 tar file (.tbz or .tar.bz2)
$ tar xvf idroot.tar - for uncompressed tar file (.tar)
  • Tar Command Options
c – create a archive file.
x – extract a archive file.
v – show the progress of archive file.
f – filename of archive file.
t – viewing content of archive file.
j – filter archive through bzip2.
z – filter archive through gzip.
r – append or update files or directories to existing archive file.
W – Verify a archive file.


Thanks for using this tutorial to explain your Linux and Unix Tar command. For additional help or useful information, we recommend you to check the official Tar website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!