12 tar command examples in Linux/Unix
The tar (Tape ARchive) tool is the most used archiving tool in Linux world. We already covered some of the compressing tools like zip/unzip, gzip/gunzip, and bzip examples which most of the time accompany this tar command. In this post, we will see on how to use tar command with simple examples. Note: TAR is not an compressing tool, but use above mention compressing tools to archive that. Syntax for Linux tar command tar [options] [TarName] [File/Directory] Tar Usage with Examples The tar command gets its name from the fact that it stores and extracts files from tape/disk archives. The tar creates the tarball with .tar extension used to take backup of the files/directories on to a tape archive by default. This just convert all the files and folders into single tar archive for easy storage and transfer. Let us see some examples of ‘tar’ usage to understand it better. Note: ‘tar’ by default produces the uncompressed tar-ball with only ‘.tar’ extension to a file. Example 1: Create a tape archive. Create a basic tape archive from the tar command. With below example we are going to club all the files/folders in default folder. sujit@linuxnix.com:~$ ls default sujit@linuxnix.com:~$ tar -cvf default.tar default/ default/ default/bootlogd default/nss default/whoopsie default/rsync default/ssh default/puppetqd default/cron default/rsyslog default/apache2 default/grub default/rcS default/locale default/ufw sujit@linuxnix.com:~$ ls default default.tar We archived the default directory in the above example, options cvf are...
Read More