
Installing Packages
Contents
Goals............................................................................................................................................. 2
Package Format
and Installation Utilities in CentOS........................................................................ 2
yum......................................................................................................................................... 2
rpm.......................................................................................................................................... 2
Mange Packages
in CentOS Using yum Utility................................................................................ 3
Installation................................................................................................................................ 3
Update or
Upgrade.................................................................................................................. 4
Package Removal.................................................................................................................... 4
To See Package Details............................................................................................................ 5
Manage Packages
in CentOS Using rpm Utility. ............................................................................. 6
Install....................................................................................................................................... 7
Package Removal
(Independent Package)................................................................................ 7
Package Removal
(Packages That Have Dependencies)........................................................... 8
Package Format
and Installation Utilities in Ubuntu......................................................................... 9
apt-get..................................................................................................................................... 9
dpkg........................................................................................................................................ 9
Manage Packages
in Ubuntu Using apt-get Utility........................................................................... 9
Installation................................................................................................................................ 9
Reinstall................................................................................................................................. 10
Update or
Upgrade................................................................................................................ 11
Package Removal................................................................................................................... 11
Manage Packages
in Ubuntu Using dpkg Utility............................................................................ 12
Install..................................................................................................................................... 12
Package Removal.................................................................................................................. 13
To See Package Details.......................................................................................................... 13
Conclusion................................................................................................................................... 14
Goals
When you have completed reading this
guide, you should understand how to install, remove and update or upgrade the Linux packages on your server system. Once
you have gone through the different sections of the guide, you will be able to
manage the packages from the backend of the system. Note: The
package format and installation types are different in both the CentOS and Ubuntu
systems; therefore, please kindly select the appropriate sections for review.
Package format and installation
utilities in CentOS
In
Ubuntu, the packages are in .rpm format. (Originally standing for Red Hat Package Manager, RPM now
stands for RPM Package Manager.)
To install a package, you can use two types of installation utilities or
commands available in Ubuntu by default -- yum and rpm.
yum
Install
the packages from the specified repositories under “/etc/yum.repos.d”. It is
the easiest way to install a package because, during package installation, its
dependencies will be automatically located and installed also. In this way, you
don't have to find and install any dependencies separately.
rpm
This
is the default installation utility in the CentOS system. The rpm installation
utility will not find and install dependencies. This utility is used to
install, update or remove specific packages given in the command.
Manage Packages in CentOS Using yum Utility
Installation
1)
To
install a package, you can use the following command. (Unlike the rpm
installation utility, you do not have to specify the full rpm name and version
here.)
yum
install <package name>
For
example, type the following command to install vsftpd service in your system:

The
vsftpd package will then be found from the specified repository. Please type
“y” to start the installation.

2)
After
installation, you will have to start the service. To do this, use the following
command:
/etc/init.d/<service
name> start

3)
You
can use the “chkconfig” command to start the service up after every reboot.
chkconfig <service name> on

4)
Now
you have successfully installed the package in your system using the yum installation
utility.
Update or Upgrade
1)
To
update or upgrade a package, you can use the following command:
yum
update <package name>
For
example, if you want to upgrade your old PHP 5.1.x version to PHP 5.2.x, all
you have to do is type the command below. (The --exclude option will exclude
the specified package.)

(Make
sure your repository includes the PHP 5.2.x version. If required, you can add
the atomic repository. For that, type the command below:
wget
-q -O - http://www.atomicorp.com/installers/atomic | sh )
2)
After
the system finds the packages and repositories, type “yes” to start the
installation.
3)
Now
you have successfully updated or upgraded the package in your system.
Package Removal
(Please
note that, while removing a package using yum, package dependencies will also
be removed.)
1)
To
remove a package, type the following command:
yum
remove <package name>
For
example, follow this command to remove vsftpd:

Type
“y” to start the uninstall.
2)
Now
you have successfully uninstalled the service from your system.
To See Package Details
1)
To
list all programs installed on your system, you can use the following command:

yum list installed
2)
If
you want to find information about a specific program, you can use the
following command:
yum
list installed | grep <program name >
For
example, if you want to check if vsftpd is installed, or if you want to find
more information about vsftpd, you can use the following command:

3)
To
know if there is an update for a particular package, please give the following
command:
yum
list updates | grep <package name>
For
example, If you want to know available updates for PHP, you can use the given
command:
4)
Now
you know the basic commands you can perform to get more information on a
package.
Manage Packages in CentOS Using rpm Utility
Install
1)
To
install a package using the rpm installation utility, use the command below. (Note
that you have to specify the full package name to install using rpm.)
rpm
-ivh <package name>
i or --install:
To install.
v: To display additional information.
h or --hash:
To print hash marks ("#")
during installation.
For
example, if you want to install the package “vsftpd-2.0.5-24.el5.x86_64.rpm”,
follow the given steps:
a)
Go to the folder or location where you put the package. (In this case, the
package is under the root home directory.)

b)
Now start the installation.
(Tip:
You do not have to type the full package name manually. Type the first few
letters then press the “tab” button.)
c)
Now you have successfully installed the package on your system.
Package Removal (Independent Package)
1)
To
remove an independent package (a package that has no dependencies),you can
follow the command below:
rpm
-e <package name>
For
example, if you want to remove vsftpd, you can follow the steps below:
a)
First, get the full package name. (Unlike yum, when using rpm you have to
specify the full package name.)

(“rpm -qa” will list all packages
installed in your system and “| grep <service name>” will find the
package name of that service.)
b)
Now that you have the full package name, combine it with the “rpm -e” command
to remove the package from your system.

2)
Now
you have successfully removed the independent package from your system.
Package Removal (Packages That Have Dependencies)
Sometimes
when you try to remove some packages using the “rpm -e” command, you will receive
dependency errors.
For
example, some of your PHP packages have crashed or you have installed different
versions of PHP packages and you have to remove the packages to get your PHP in
working condition. If your try to remove a package, you will get the following
error:

1)
In
this situation, if you are sure what you are doing, you can remove the package
forcefully without dependencies using the following command:
rpm
-e --nodeps
This
will remove the package forcefully without any dependency issues.

(Note:
Please do not try the above command if you are not sure about what you are
doing, or if you are testing your system, because this action may crash the
service and the working of associated dependencies.)
2)
Now
you have successfully removed the package from your system without any
dependency issues.
Package Format and Installation Utilities
in Ubuntu
In
CentOS, the packages are in .deb format. To install a package, you can use two
types of installation utilities or commands available in CentOS by default -- apt-get
and dpkg.
apt-get
Install
the packages from the specified repositories from the file
“/etc/sorcem.repos.d”. It is the easiest way to install a package because, during
package installation, its dependencies will be automatically located and
installed also. In this way, you don't have to find and install any
dependencies separately.
dpkg
This
is the default installation utility in the Ubuntu system. The dpkg installation
utility will not find and install any dependencies. This utility is used to
install, update or remove specific packages given in a command.
Manage Packages in Ubuntu Using
apt-get Utility
Installation
1)
To
install a package, you can use the following command. (Unlike the dpkg
installation utility, you do not have to specify the full rpm name and version
here.)
apt-get
install <package name>
For
example, type the following command to install zip in your system.

2)
The zip package will be found in the specified repository. Please type
“y” and press enter to start the installation.

3)
Now you have successfully installed the zip service in your system.
Reinstall
1)
If
you want to reinstall a damaged package, you can use the following command:
apt-get
--reinstall install <package name>
