Tar is one of the most universal installation/archiving tools around. Where the rpm package falls short beyond Red Hat (and a few choice distributions), tar picks up all the slack. Working across all Linux distributions, tar is the choice of all hackers/crackers/coders/geeks/phreaks/hard_core_users/you/and/me around the globe. The plain and simple reason for tar's popularity? Specification, baby!
Linux 101 installments are intended to bring IT professionals unacquainted with Linux up to speed quickly on the alternative operating system's more basic features and uses.
With most installation packages, you take what you’re given. Nearly all "wizard-like" installation packages were created on a machine similar to yours—but it wasn't your machine. No matter how hard you try, you're just not going to have the same machine as every coder out there. Fortunately, when you're installing from a tar file, it's all about your machine.
Now, to be fair, tar is not an installation package but simply an archiving package. What tar does is pack all the source for the installation into one complete directory. For example, the file
would be a tar file, in zipped format, of the this_application directory. The this_application directory would contain all the ingredients for a freshly brewed cup of your favorite program, this_application.
But how do we get from this_application-1.0.0.tar.gz to running this_application?
The first step in running our sample this_application-1.0.0.tar.gz is to unzip the package so the tar file is ready for unpacking. To do this, run
and voila! The gunzip application will uncompress the package leaving you with this:
Now that you have your tar file unzipped, it's time to unpack the directory. This unpacking can be done with countless arguments passed to the tar application. However, for the sake of simplicity, we are going to stick with only the essentials. The common flags passed to tar are the following:
- x - extract (unpack the contents of this file)
- v - verbose (give me a verbose listing of the files being processed)
- f - use archive file or device ARCHIVE
With these flags, you can unpack nearly all tar files by running the command
tar xvf this_application-1.0.0.tar
Once you run this command, you will be left with a directory—in this case
Within this directory will be all of the source and readme files necessary for the installation of the package.
The above two steps can be combined into one step by adding the z argument to the tar command, like this:
tar xvfz this_application-1.0.0.tar.gz
Typically, you can install source packages (all of the files within the newly created directory) with a few simple steps. (Note: su into root to run the following).
The first thing you will want to do is check to see if there is a readme, install, or readme.install file. If one or all of these files exist, read them! Beyond outstanding directions, the typical installation of source packages goes somewhat like this:
From within the newly created directory, run the following command (exactly as written):
This command compares the state of your system and installed packages to make sure they are compatible with the program. If the ./configure works, a new file will be created called the makefile.
Once the makefile is created, you need to run two commands. First:
The make command compiles the application. Like any program’s source code, this application must be compiled, and make is the command that works in conjunction with the gcc compilers to do just that.
Once make has completed its task, and the source code is compiled, it's time to actually install the application.
The final step is to run
This will finally put the compiled source code together into a working application that can be run from either the installed directory or from the user’s $PATH (think global).
Yes, installation with tar files is a bit more complex and takes a little longer than the typical setup, exe, or rpm format. However, the benefit of running an application that was compiled specifically for your machine outweighs any and all time inducing obstacles. Installing from tar files will result in better, more efficient packages.
For more information, take a look at the tar man page (run man tar).
Jack Wallen is TechRepublic’s Linux resident expert. When he’s not out busting up mountain bikes and helping wounded MCSEs back to camp, he’s hacking away diligently at one of his many Linux-powered PCs.If you'd like to share your opinion, please post a comment below.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.