Some people at the Linux SIG expressed an interest in using tar with Linux.
The rest of this article assumes basic familiarity with using the command line in Linux. A simple way to get to the command line from inside your gui is to open a console program like konsole or xterm from your Start Applications Menu.
tar is a very handy program. It was originally developed for creating archives of files on magnetic tape for backups, etc. Nowadays, it is used primarily as a simple method to package a group of files into one file for ease of distribution. Many Linux "source" packages come in this format. It is also handy for making simple compressed backup archives.
When it's created "right" (IMHO), a tar archive consists of a single directory with files (and possibly subdirectories) in it so that if you unpack it using default options, what you get is a new subdirectory with all the separate files in it. This way you know exactly where all of the parts are and they're not mixed in with anything else.
In addition to creating archives and extracting files from them, tar can also use one of several compression programs to shrink the size of the archive. The two most common compression types are zip and bzip indicated by using the z and j flags respectively.
Usually, a tar archive is named some-name.tar.
If it was zipped it is named some-name.tar.gz.
If it was bzipped, it is named some-name.tar.bz.
Of course, this is the wild woolly web and people do what they will, so the above is not a hard and fast rule. If you're not sure what you've got, type
file some-file
and it will tell you what kind of file some-file (probably) is.
So, if something you want comes in a tar archive, you (put it or) download it into a working directory as a regular user (I use /home/bigbird/installs for good stuff and /home/bigbird/sandbox for temporary things or ones I'm not sure about). Then, you extract all or some of the files. Once the files are extracted, you need to put them where they'll do some good.
If they comprise a program, you usually run configure and make scripts that (hopefully) come with the package and then, as superuser (su or sudo), run a make install to put the files in the right protected places in your operating system. To cover this adequately would require a book chapter, but the above steps often work as is.
If the files are not a program or are too simple to require all the work of creating configure, make, and install scripts, you just move them to where you want them on your computer and then make sure they have the right permissions set using chmod if necessary.
If any of the files are executable (e.g. scripts or binary programs), you need to put them where the rest of your system can find them. Some files will need to be put in special places e.g. .jar files need to go where your java systems know to look for them.
Simple executable files like shell scripts or binary programs usually need to be in a directory that is searched by the operating system when you tell it to do something. In Linux, this information is stored in the shell variable PATH. At the command line, type
echo $PATH
and you'll see where Linux is looking.
bigbird ~: $echo $PATH
/usr/local/qt-3.3.2/bin:/usr//bin:/bin:/usr/bin::/usr/local/bin:/usr/X11R6/bin:/usr/games:/home/bigbird/bin
bigbird ~: $
I keep all my personal programs in /home/bigbird/bin and I have added that to the end of my PATH so that my programs will be found by the system, but will not override any program of the same name already present in the system.
Back to tar:
tar, like many programs in Linux, has a ton of options, but most of them are for special cases.
To extract a tar file into the current directory:
tar -xvf some-name.tar
To extract a tar.gz file into the current directory:
tar -xvzf some-name.tar.gz
To extract a tar.bz file into the current directory:
tar -xvjf some-name.tar.bz
See
http://www.fluidthoughts.com/howto/tar-gzip/for a few more details or type
man tar
for the whole enchilada.
TIP:
Another use for tar that's a little less obvious is to use it as a copy program for moving groups of files around on your disk(s) or network. Using tar alone or with pipes in a shell script can be a handy way to package up a pile of files on the fly and send them on their way as a single job step - possibly using file compression to cut down the bandwidth/transmission time requirements.
If you're doing a lot of this, take a look at the rsync command. It's great for copying just what has changed between two locations.
HTH
Joe