How to install Software in Linux
I'm working on most of the other methods of installing software in Linux but for now I'll only cover installing from source-code.
You've probably downloaded a package with an extension of one of the following: tar.gz, tar.bz2 or zip. As a user from a previous OS you are most likely familiar with the zip extension but the other may seem archaic to you. They are archives that use either the gzip, bzip (tar.bz) or bzip2 compression and if you're on a modern, popular distribution of Linux you can right click the archive and extract it. Much like you would do on Windows.
I am going to cover extracting these from the shell however for the sake of it as it is just important basics. Simply navigate to the location where you downloaded the file, for example, if it's on your desktop you'd do cd (change directory) like this.
cd /home/<username>/Desktop/
Be sure to replace <username> with your own and obviously exclude the brackets. You may want to check if the file is present by prompting the shell with the ls command (list directory contents).
Extracting tar.gz.
tar -zxvf filename.tar.gz
And extracting from tar.bz2 all you need to do is change 'z' to 'j'.
tar -jxvf filename.tar.bz2
If the filename is long, type the first few characters thereof and press the 'TAB' key on your keyboard to auto-complete the line. The above command will create a folder that will contain the name of the original file. Change your working directory to the newly extracted directory with the cd command. Example:
cd My_package_filename/
Check again if your files are present within the new directory with the ls command, if there is an INSTALL file or a README file you might want to review their instructions with the more command. Issue as follows:
more INSTALL
Many packages have specific parameters to be used or just specific instructions on installing and compiling to be aware of. If nothing, you can now safely start the process of actually putting the program into place after configuring, compiling and installing.
./configure
This command checks whether you have the necessary requirements to run the software. If you encounter an error message be sure to check the package's documentation and search around forums in case the problem has been addressed before. It also creates a Makefile, the file that we will compile using the make utility. Before we can do this we need to change to the root user (administrator) with the su command (switch user).
su root
Enter the password when prompted. If all went well we can now compile.
make
Then:
make install
Assuming all went well, you will in most cases be able to run the application by just entering the name in the shell and hitting enter but in case that doesn't work, refer to the documentation of the program on launching the program.
Update
For those who can't remember all the tar arguments here's a little script that will do the work for you.
#!/bin/bash
# tar files and folders
NAME=$1
LOCATION=$2
if [[ -z $LOCATION ]]; then
echo "tarer <compressed-name>.tgz </location/to/start>"
echo " - use absolute location if planning restores."
exit;
fi
tar -czpvf "$NAME".tgz "$LOCATION"
