How to install a Software in Linux


After a fresh installation of a Linux distro your Laptop/PC/Server will contain almost all the essential software required for your system to work. But situations may arise where you have to depend upon additional software to perform your day to day activities. In this post we will look how to install a software in Linux.


In computer science a software package is a bundle of files organized  inside a single file, which when installed will instruct the computer to perform certain tasks. The files organized inside a package will include executables, configuration  and library files. Installing a package is nothing but copying or extracting the files organized inside the package to specific locations of the file system.  Every operating system has a Package Management System (PMS) to Install, Remove, Upgrade, Resolve dependencies.

Package management is one of the distinctive feature of Linux distros.  When it comes to Linux distributions there are 3 major distros that stands out from the rest.
  • Debian
  • Redhat
  • Slackware
A majority of Linux distros are  derived from one of these 3 major distros. The reason why we say the other distros are derived from Debian, Redhat or slackware is because rest of the distros has adopted package management system present in Debian, Redhat and Slackware OS.

Debian and its derivatives use dpkg Package Management System and their software package have the extension .deb. Debian, Ubuntu, Linux Mint, Elementary OS are examples of Linux distros following dpkg.

Redhat and its derivatives use RPM Package Management System and their software package have the extension .rpm. RHEL, Fedora, CentOS,  OpenSUSE are examples of Linux distros following RPM

Slackware and its derivatives uses a much simpler tgz package system which is just an ordinary compressed tar file. Slackware packages have the extensions .tgz, .txz. Vector Linux, Slax, Stux, MiniSlack are examples of Linux distros following tgz package system

Install from packages

In this section we will see how to install a software from a package

dpkg for Debian based distros

dpkg is the package manager tool in debian based distros for installing, removing  upgrading and managing debian packages. The syntax to install a package with dpkg command is
dpkg -i package_name
example:
To install telnet client package, execute
dpkg -i telnet_0.17-36build1_amd64.deb
Sample Output:
Selecting previously unselected package telnet.
(Reading database ... 54238 files and directories currently installed.)
Unpacking telnet (from telnet_0.17-36build1_amd64.deb) ...
Setting up telnet (0.17-36build1) ...
update-alternatives: using /usr/bin/telnet.netkit to provide /usr/bin/telnet (telnet) in auto mode.
Processing triggers for man-db ...

rpm for Redhat based distros

rpm is the tool in Redhat based distros for  managing RPM packages. The syntax to install a rpm package using rpm command is
rpm -i package_name

example:
To install telnet client package, execute
rpm -ivh telnet-0.17-60.fc21.i686.rpm
Sample Output:
Preparing...                          ################################# [100%]
Updating / installing...
   1:telnet-1:0.17-60.fc21            ################################# [100%]

installpkg for Slackware based distros

installpkg is a tool used by Slackware based distros for installing txz, tgz packages. The syntax for using installpkg is
installpkg package_name

example:
installpkg /home/calypso/Downloads/gcc-4.8.2-x86_64-1.txz
Sample Output:
Verifying package gcc-4.8.2-x86_64-1.txz.
Installing package gcc-4.8.2-x86_64-1.txz:
PACKAGE DESCRIPTION:
# gcc (Base GCC package with C support)
#
# GCC is the GNU Compiler Collection.
#
# This package contains those parts of the compiler collection needed to
# compile C code.  Other packages add C++, Fortran, Objective-C, and
# Java support to the compiler core.
#
Executing install script for gcc-4.8.2-x86_64-1.txz.
Package gcc-4.8.2-x86_64-1.txz installed.

pkgtool for Slackware based distros

pkgtool is a simple, Text-based User Interface tool available in Slackware based distros for managing packages. For installing a package, instead of giving package name we have to provide the directory containing the packages. The tool will automatically detect the software packages and ask the user whether to continue with the installation or not



Installation using command line Package Manager 

Most packages in Linux  depends on another package. ie In order to install package A another package B should be available in the system. If not, package B need to be installed prior to installing package A. And package B might have its own dependencies.
 In the above example , an attempt to install the vim package failed due to missing dependencies. And the dependent package itself is dependent to another  package Checking dependencies for each package and installing them manually can be annoying. To avoid such situation we use interactive command line package managers  with automatic dependency resolution. apt-get, yum, dnf are examples of such utilities. The above said utilities will require a well maintained software repository to work effectively. A software repository is nothing but a storage location of software packages which can be accessed locally or over a network.


apt-get for Debian based distros

apt-get is the command-line package management utility in Debian based distros. apt-get is one of the utilities that comes with APT ( Advanced Packaging Tool).
Syntax to install a package with apt-get utility is
apt-get install package-name
Example:
To install vim package using ap-get command, execute
apt-get install vim
Sample Output:

 

yum for Redhat based distros

yum (Yellowdog Updater modified) is the command-line utility used by Redhat based distros that works on RPM Package Manager. Tasks that can be performed with yum are
  • install package
  • update package
  • remove package
  • auto-resolve package dependency
  • listing installed and available packages
Syntax to install a package with yum utility is
yum install package_name

Example:
To install vim package using yum command, execute
yum install vim
Sample Output:



 

Installation using Graphical Utilities


Ubuntu Software Center
Most of the Linux distros are shipped with a Graphical Package Management utility for installing, removing and updating software. It is just a front-end to  package managers like dpkg and rpm. Like the command line utilities  graphical utilities  will also require one or more software repositories to work. gnu-software and Ubuntu Software Center are two most widely used graphical package management utilities

gnu-software running on Fedora
To install a software you just have to enter the software name in the search field and if the software is present in the repository, the utility will display it. Within few mouse click the software will be installed in your system. Graphical utilities have additional features like auto-update checker, repository management and even purchase of proprietary software.

Installation using binary/run files.


Binary (.bin)/run (.run) files are self-extracting executable files.  They are like .exe files in a Windows operating system. You can run a binary/run file from a terminal or by double-clicking, provided the file has execute permission set.

To run a binary/run file first make sure execute permission is set
chmod +x filename.bin
chmod +x filename.run
Then run the file as
./filename.bin
./filename.run
example:
./postgresplus-9.0.2-1-linux.bin

Sample output:

 

Compiling and Installing from source.

This method requires a bit more Linux exposure than the other methods mentioned in this post.  In most cases sources will be available online in archive/compressed form. You will have to download the file and unpack it first. Then the source code is compiled, which will create  an  binary install files.

There is no fixed approach to install from source but the general idea is the same. once the archive is downloaded and extracted cd into extracted path.
cd /path/to/extracted_directory
The extracted directory will usually contain a README or INSTALL file which contains the installation instructions along with other information regarding the software. It is a good practice to go through these instructions before starting the installation.
A typical installation from source involves three steps
(a)
./configure
This will run some tests to check whether the system meets all the requirements needed to run the software. Once the system check is completed and the system requirement is met, a 'Makefile' is generated which contain rules on how the software should be compiled.

(b)
After running the configure script, we are now ready to compile the software with make command. i.e to compile, execute
make
Sample output:
(c) After successful completion of compiling its now time to install the software with make install command
make install
Sample output:

In some cases 'configure' file will not be available inside the extracted directory instead a file named make will be present. In such situation skip the first step and just run make and make install

 

 

Install from a pre-compiled binary archive

Some Linux software are available in the form of a pre-compiled binary archives. Which means you just have to extract the contents of the archive to a desired directory. That's all. The extracted files will include executable files. You can start running the program by double-clicking the executable file or running the executable file from a terminal. One thing you need to know is whether you are running a 32 bit or 64 bit OS. You can find the system architecture by executing
uname -m

If the command output is x86_64 you are running 64 bit kernel or if output i686 then it is a 32 bit kernel. While downloading the archive get the file corresponding to your system architecture and extract the contents to a desired directory

 

Installing Microsoft Windows application with wine

You can install and run applications native to Windows OS using Wine. But first you have to install Wine in your OS using any of the methods mentioned above. To run a program with wine, execute

wine file_name.exe

I

Comments

Popular posts from this blog

Understanding awk command with examples

Understanding sed command with example -Part 1