SP-Lab2
SP-Lab2
Lab # 2
System Programming
Objectives:
Complete Understanding of Commands regarding the installation of a package on both
RHEL & Debian Platform
Package Management:
Most Linux distributions have a package management system with online repositories
containing thousands of packages. This makes it very easy to install and remove applications,
operating system components, documentation and much more. We first discuss the Debian
package format .deb and its tools. This should be similar on Debian, Ubuntu, Mint and all
derived distributions. Then we look at the Red Hat package format. rpm and its tools rpm and
yum. This should be similar on Red Hat, Fedora, CentOS and all derived distributions.
Repository:
A lot of software and documentation for your Linux distribution is available as packages in one
or more centrally distributed repositories. These packages in such a repository are tested and
very easy to install (or remove) with a graphical or command line installer.
.deb packages:
Debian, Ubuntu, Mint and all derivatives from Debian and Ubuntu use .deb packages. To
manage software on these systems, you can use aptitude or apt-get, both these tools are a front
end for dpkg.
. rpm packages:
Red Hat, Fedora, CentOS, OpenSUSE, Mandriva, Red Flag and others use. rpm packages.
The tools to manage software packages on these systems are yum and rpm.
Dependency:
Some packages need other packages to function. Tools like apt-get, aptitude and yum will
install all dependencies you need. When using dpkg or rpm, or when building from source,
you will need to install dependencies yourself. deb package management:
There are three tools to manage deb package.
• dpkg
• apt-get
• aptitude
dpkg:
dpkg is a low-level tool to manage packages in Debian because you have to manually resolve all
the dependencies.
Here are the few commands for dpkg
(Note make sure you are login as root or switch user using sudo su -)
dpkg -l:
it will show the list of all the packages installed on your Debian platform.
By using dpkg -l you can also get the information about individual package by dpkg -l
$package. ii in the beginning mean package is installed.
dpkg -S:
You can find the package that installed a certain file on your computer with dpkg -S by using
the following syntax dpkg -S filepath.
dpkg -L:
you can obtain the list of files installed by specific package with dpkg -L by using syntax
dpkg -L $package
apt-get
Debian has been using apt-get to manage packages since 1998. Today Debian and many
Debian-based distributions still actively support apt-get, though some experts claim aptitude is
better at handling dependencies than apt-get
apt-get update:
you can download the names, description and version of all the packages available on all
configured repositories of your system. The output will look like this
apt-get upgrade:
you can securely update all the software installed on your system with apt-get update
apt-get clean:
apt-get keeps a copy of downloaded packages in /var/cache/apt/archives. You can remove
the .deb files from that folder with apt-clean apt-get install:
you can install new package with apt-get install by using syntax apt-
get install $package
apt-get purge
You can purge one or more applications by appending their name behind apt-get purge.
Purging will also remove all existing configuration files related to that application. The
screenshot shows how to purge the rsync package.
aptitude:
Aptitude is another way to manage packages on Debian. The main advantage aptitude is the
capability to automatically resolve dependencies. It has same function as apt-get and syntax is
also same with aptitude.
Here are some commands and their functions
aptitude update:
To synchronize with the repositories.
aptitude upgrade:
aptitude safe-upgrade:
To patch and upgrade all software to the latest version on Ubuntu and Mint.
.rpm
The Red Hat package manager can be used on the command line with rpm
Here are the few commands for rpm
rpm -qa:
You can obtain the list of all the software/packages installed on your system with rpm -qa
You can also check whether particular package installed on your system by
rpm -qa | grep $package
rpm -q:
you can verify whether particular package install on your system by rpm -q $package
Rpm -Uvh:
You can install or upgrade any package with -Uvh switch. The -U switch is the same as -i for
install, except that older versions of the software are removed. The -vh switches are for nicer
output
Note:
Rpm cannot resolve dependency itself so you have to manually install all the dependencies.
rpm -e:
You can remove any package with rpm -e $package
/var/lib/rpm:
The rpm database is located at /var/lib/rpm. This database contains all meta information about
packages that are installed (via rpm). It keeps track of all files, which enables complete removes
of software.
Yum:
Yum is another tool to manage packages in Red hat or Fedora Enterprise systems. The
advantage to yum over rpm is that it resolve dependencies itself so you can install packages
much easier than rpm.
Yum list:
You can obtain the list of all the packages installed on your system with yum list.
You can get the total number of packages installed on system by yum list | wc.
You can check all the versions of one package by yum list $package
Yum search:
Yum can search for particular package by using
Yum search $package
yum provides:
To search for a package containing a certain file (you might need for compiling things) use
yum provides $filename
yum install:
To install an application, use yum install $package. Naturally yum will install all the
necessary dependencies.
yum update:
To bring all applications up to date, by downloading and installing them, issue yum update.
All software that was installed via yum will be updated to the latest version that is available
in the repository
Yum grouplist:
Yum grouplist is used to see list of all available software groups.
Yum groupinstall:
You can install set of application brought together by group by using groupinstal $groupname
Lab Task:
• Install any package using dpkg.