Installing packages on linux was a biggest mystery to me when I started learning unix/linux, so I thought to write a complete guide on how to install/un-install packages using yum and apt-get in Linux. In Linux softwares or applications that execute on machine is called packages. We will go through:
- RPM (Red hat package manager).
- apt-get (Debian based package manager)
- yum (yum some how wraps around RPM but it is very easy and friendly to use)
What is a package?
Package is a bucket of files needed to install a specific application that runs on Linux, how ever some times package have dependencies, and these dependencies are called libraries, and these must be installed before installing the application, I will write a specific article on how can we install a package from source code and install its dependencies manually. Packages are available in two kinds:
Binary packages comes with source code already compiled, and software can be used as soon as it is installed.
These packages contain a file that needed to be complied first, you may need a compiler installed on your machine to compile and use the software, how ever this is lengthy and complex process.
What is a package manager?
For quite some time now package managers are available by default on linux operating systems, you don’t need to have any technical knowledge to install a package, packages are already placed on some remote servers (in binary form) and they can be installed with one command, their are various package managers available, but most prominent are:
- yum (yum uses rpm at back end, its preferable over rpm, because it will automatically resolve and install dependencies issues, yum is mostly used on Cent OS distribution of Linux)
- apt-get is same as yum, it uses dpkg at back end to install packages, it is available on Debian based Linux distributions.
Install packages using package manager
We are going to install package ‘wget’ using both yum and apt-get and see how they are installed on the different machines.
yum install wget
apt-get install wget
Here the package manager is yum and apt-get, and it will install ‘wget’ for us, and resolve any dependencies, you might see the following output if you run the command (this output will be at the end of the install log)
Transaction test succeeded
Installing : wget-1.14-10.el7_0.1.x86_64 1/1
Verifying : wget-1.14-10.el7_0.1.x86_64 1/1
Now wget is installed, you can run the following command to see where is it installed
This command will return the path where this program is installed, it will print out something like:
you can then use this path to fork or load this program, let see an example usage of wget
#you can directly use wget as well
These are the two ways you can use wget, this will produce the same results.
How you can remove an installed package
Some times you need to remove an installed package as well, because you might not need it ?
yum remove wget
apt-get remove wget
Note: On ubuntu you can use ‘sudo’ if you are not logged in as root.
How to upgrade packages on Linux
On Linux you can easily upgrade packages, by just issuing a single command. It will automatically checks updates for the packages that are currently installed on your machine and then performs the update for them.