Organizational Research By

Surprising Reserch Topic

Question:how to use tar unix command on command line?


tar

Tar is a program that archives files into a single package that you can move around easily. After using the tar command ,you are left with a single tar file which is referred to as a ‘tarball’. A tarball is compressed ,but you can compress it further by adding the ‘z’ flag which gzips it into a smaller file. This is how I typically use tar:


tar cvzf mytarball.tgz .

The ‘c’ flag means “create a tarball”, the ‘v’ flag stands for “verbose mode” or “show every file that is compressed as it happens”, the ‘z’ flag means “gzip the tarball further (hence the .tgz extension instead of .tar)” and the ‘f’ flag means “use the tarfile argument as the name of the tarfile”. The argument ‘mytarball.tgz’ is the name of the file. You can name it whatever you like; the extension does not matter – I just like using .tgz. The last argument ‘.’ means include all files in the current directory and all subdirectories. After running this command you now have a compressed ‘mytarball.tgz’ file. You can move this file around wherever you need it. If I needed to download an entire site via FTP I would run this command and then just download the single tarball rather than downloading many files individually.

The opposite of archiving is unarchiving (o rly?). To unarchive a gzipped tarball use the following:


tar xvzf mytarball.tgz

It’s that simple. The flags are the same except you use ‘x’ instead of ‘c’ which means ‘extract’. This will uncompress your tarball in the current directory you are in, maintaining the original directory hierarchy.

asked Sep 13, 2013 in LINUX by anonymous
edited Sep 12, 2013
0 votes
23 views



Related Hot Questions



Government Jobs Opening


...