We usually download linux programs through package handling tools such as yum and apt-get. Download programs through package handling tools is easy, but not all programs is available in your Linux distribution repository. Sometimes, we need to download the source code, compile and install manually.
Usually, source code are compress in the archive format, its either tar.gz (.tgz) or bz2. The command uses to extract these archive is tar. Let say your archive is ns2.29.tar.gz, then you can decompress it and extract to your folder like this
tar -xzvf ns2.29.tar.gz -C /usr/src
-C is to indicate tar where to store the extracted files, you can extract the source code any place you like, such as home directory.
Before you start configure and install, please always read the readme files tag alone with tarball, it will sometimes brief you the specific steps to install the programs and also the requirements to fulfill before compile the source code.
Common open source programs source code comes with configure files and makefiles. Because those programs usually are cross platform compatible. That means it can be compile in different platform such as Unix, Linux, BSD etc, given the required library installed and the dependencies solved. Therefore, before start to compile and install, you usually need to configure.
Configure scripts will check whether all the libraries and dependency files are there or not. If it is not there it will pause and indicate you what is missing. At this moment, you need to search for the lib and install that before you can continue to configure.
Sometimes, the libraries are install, just the lib location are not the same as specified in config file, a good configure script, will have allow you to set some option, such as alternatives lib path, prefix of where you want to install the programs to. Display the options, you do this.
When it is done, now you can compile your source code. To compile all the source code and produce the binaries, you do this
Some packages contain more than one programs, do
To compile all and turn all into binaries.
The last steps, is to install, usually you need root privilege to install packages.
sudo make install
Some of the makefiles have other options such as uninstall, clean etc. So to uninstall, you can do this:
sudo make uninstall
What make install do is just copy the binaries created to specified path, and uninstall is just remove them from the specified directories. Makefiles and configure scripts sometimes might be vary, sometimes the tarball will tag alone with friendly script with names “runme.sh”. You just need to run the run me script, It will configure, make and install for you.