- August 29, 2015
- Posted by: Surender Kumar
- Category: Linux
Installing Software in Linux
Installing software in Linux is sometimes very complicated depending upon the source of installation package. In Windows, every program comes with a setup.exe or setup.msi program which is very easy to install. While Linux software can be almost that easy to install, you will sometimes find software that seems to fight every step of the way. I can’t cover all the problems you might run into, but I’ll try to point out some basics and some advanced ways you can use. If you are a Linux system administrator, you might be interested to read this section.
Software tends to come in the form of “Packages”. In the Windows, a package is a setup.exe, setup.msi or program.zip file. In Mac, a package is a program.dmg or a program.sit file. But in the Linux, there are several kinds of packages, and each Linux distribution has its own preferred package format.
Installing software on Linux involves package managers and software repositories, while in Windows you download the software.exe from internet and run it to install. If you’re new to Linux, this can seem like a dramatic culture shift but it is true.
While you can compile and install everything yourself on Linux, package managers are designed to do all the work for you. Using a package manager makes installing and updating software easier than on Windows.
Each Linux distribution hosts their own software repositories. These repositories contain software packages specially compiled for each Linux distribution and version. For example, if you’re using CentOS 7, the repositories you use contain packages specially compiled for CentOS. A Ubuntu user uses a repository full of packages specially compiled for their version of Ubuntu distribution.
Third Party Repositories
While Linux distributions ship with their own repositories pre-configured, you can also add other repositories to your system. Once you have, you can install software from that repository and receive updates from it using your package manager. The repository you add must be designed for your Linux distribution and package manager. Some third-party applications also use their own software repositories. For example, when you install Google Chrome on Ubuntu, it adds its own apt repository to your system. This ensures you receive updates to Google Chrome through Ubuntu’s Update Manager and standard software installation tools.
For example, to add EPEL (Extra Packages for Enterprise Linux) and additional repositories on CentOS and Red Hat which are not included in the official CentOS or Red Hat Enterprise Linux repositories, run the following commands:
[root@centos ~]# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm --2015-08-29 14:16:23-- http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 188.8.131.52, 184.108.40.206, 220.127.116.11, ... Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|18.104.22.168|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 14524 (14K) [application/x-rpm] Saving to: ‘epel-release-7-5.noarch.rpm’ 100%[==============================================================================================================================>] 14,524 41.3KB/s in 0.3s 2015-08-29 14:16:24 (41.3 KB/s) - ‘epel-release-7-5.noarch.rpm’ saved [14524/14524] [root@centos ~]# rpm -Uvh epel-release-7*.rpm warning: epel-release-7-5.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:epel-release-7-5 ################################# [100%] [root@centos ~]#
You install the EPEL repository by downloading the appropriate RPM package for your system and installing it. If you get a File Not Found error message when trying to download the package, the version number might have changed. You can access the latest version of the RPM installer from the Fedora EPEL wiki page. The command I run above is for CentOS 7.
If you are using CentOS and Red Hat Enterprise Linux 5.x, use the below command:
[root@centos ~]# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm [root@centos ~]# rpm -Uvh epel-release-5*.rpm
If you are running CentOS and Red Hat Enterprise Linux 6.x, use the following command:
[root@centos ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm [root@centos ~]# rpm -Uvh epel-release-6*.rpm
The standard Linux package format is RPM. RPM (Red Hat Package Manager) is a packaging system originally developed by Red Hat and widely used in the Linux community. Distributions using it include Fedora, Mandriva, Red Hat, and SUSE. An RPM package file normally will be named something like program-version-other.rpm.
Another popular package format is DEB, the Debian software package. Debian packages and the Advanced Packaging Tool (APT) were the first to introduce several advanced features that are now common, such as automatic dependency resolution and signed packages. Debian packages are used by Debian GNU/Linux, and distributions based on it, including Ubuntu, Knoppix, and Mepis etc. A Debian package file normally will be named something like program-version-other.deb.
To install a software, you need to be logged on with root user or alternatively, you have to use su or sudo commands. su command makes you superuser for a running session (until you exit) while sudo command gives you superuser privilege for just single command.
Package Installation in RedHat and Fedora Distributions
There are various tools for working with RPM packages, but the one you will most commonly use is yum. The yum (Yellowdog Updater, Modified) is an easiest tool of Linux package management. It is so easy because it not only keeps track of what packages being installed, but also resolves the dependencies for software packages and can also download the required packages from the internet for you.
Syntax for running the command is yum install packagename -y. If you want to take superuser privilege for single command, you can use sudo yum install packagename -y. Enter the password for superuser and hit enter.
[root@centos ~]# yum install samba -y Loaded plugins: fastestmirror, langpacks base [output cut] http://centos.excellmedia.net/7.1.1503/os/x86_64/repodata/9c92f78fb6f22491ea7414f5a844ad08c604139b151d4c702f2c0d6ae092c86f-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to centos.excellmedia.net:80; Connection refused" Trying other mirror. (1/4): extras/7/x86_64/primary_db | 74 kB 00:00:00 (2/4): base/7/x86_64/group_gz | 154 kB 00:00:04 (3/4): updates/7/x86_64/primary_db | 3.3 MB 00:01:43 (4/4): base/7/x86_64/primary_db | 5.1 MB 00:01:57 Determining fastest mirrors * base: mirrors.vinahost.vn * extras: mirrors.vinahost.vn * updates: mirrors.vinahost.vn Resolving Dependencies --> Running transaction check ---> Package samba.x86_64 0:4.1.1-31.el7 will be updated ---> Package samba.x86_64 0:4.1.12-23.el7_1 will be an update [output cut] --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Transaction Summary ======================================================================================================================================================================== Upgrade 1 Package (+5 Dependent packages) Total download size: 6.2 M ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 237 kB/s | 6.2 MB 00:00:26 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 Importing GPG key 0xF4A80EB5: [output cut] Dependency Updated: libsmbclient.x86_64 0:4.1.12-23.el7_1 libwbclient.x86_64 0:4.1.12-23.el7_1 samba-client.x86_64 0:4.1.12-23.el7_1 samba-common.x86_64 0:4.1.12-23.el7_1 samba-libs.x86_64 0:4.1.12-23.el7_1 Complete!
To remove the package, use yum remove packagename command.
yum does not keep a local copy of your package database by default, so normally there is no need to update it. To install all available security patches and bug fixes, use yum update command. You can also update a single package with yum update packagename command.
To install a standalone package, you can also use rpm -ivh packagename.rpm command, where packagename.rpm is the name of the package for your environment.
Package Installation in Debian and Ubuntu Distributions
The apt-get is a tool used for DEB packages. The apt-get command does what yum does for RPM packages. Like yum, apt-get can download and install packages from a configured repository over internet.
To install package if you are using Debian or Ubuntu linux distributions, use the apt-get install packagename -y command. To remove the software, use apt-get remove packagename command.
The repositories that contain installation packages might reside on the internet or on a disc, APT keeps a local database on your hard drive with a list of all available packages and where to find them. This database needs to be explicitly updated. To update the APT database you can use apt-get update command.
A common practice is to update your package database first, and then upgrade all the packages that have patches or security updates to install. You can combine both commands as apt-get update; apt-get upgrade.
In graphical mode, installation of packages are managed by using special software for example Software Center in Ubuntu as shown in image below.
But we will not cover graphical methods in our tutorials. Everything we will do is through command line mode.
Package Installation in Other Distributions
Some other Linux distributions have their own way of managing packages, notably SUSE. SUSE uses RPM as its native package format, but has its own high level tool to manage system software installation.
SUSE Linux uses a tool called yast (Yet Another Setup Tool) to perform all kinds of system administration tasks, including installing software. Zypper is the command line package manager using the libzypp library for installing, updating and removing packages as well as for managing repositories. It is especially useful for accomplishing remote software management tasks or managing software from shell scripts. The syntax of zyper is zypper [global-options] command [command-options] [arguments]. Below is the quick list of commands supported by zypper:
zypper # to print the list of available global options and commands zypper help search # to print help for the search command zypper lp # to see what patch updates are needed zypper patch # to apply the needed patches zypper se sqlite # to search for sqlite zypper rm sqlite2 # to remove sqlite2 zypper in sqlite3 # to install sqlite3 zypper in yast* # to install all packages matching 'yast*' zypper up # to update all installed packages with newer versions, where possible
Install .tar or .tar.gz Packages Downloaded through Internet
A tarball (.tar package) could contain anything. Until you actually open it, you have no way of assuming how to install it. Each package should be treated with different approach. Every package will provide instructions on how to install the application. You should always look for a text file called README, INSTALL or something like this. Checking out the website of the publisher might also help.
Since every package is different, there’s no universal way to process every tarball in the world. In the Linux/Open Source software world, GNU Autotools got a wider adoption. Lets see an example:
Suppose you downloaded firefox-40.0.tar.bz2 from internet. Create a new directory named firefox using mkdir command, copy the downloaded file to it using cp command and navigate to directory using cd command. Then enter the following commands:
[root@centos firefox]# tar -zxvf firefox-40.tar.bz2
The above command extracts the files into one directory with the same name as .tar packages. Now, move to newly created directory and run the following commands:
[root@centos firefox]#cd firefox-40* [root@centos firefox-40]# ./configure [root@centos firefox-40]# make [root@centos firefox-40]# make install
That’s all for this section.
In the next section, we will look into how to Configure Local Yum Repository so that you can use on your own system and install the packages using yum command even if you are not connected to internet.