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 used to rip a collection of files and directories into highly compressed archive file commonly called tarball or tar, gzip and bzip in Linux. The tar is 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.
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/
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)
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.