4. Package management¶
4.1. Outline¶
Debian and Ubuntu packages.
Advanced Package Tool (APT) for package installation, removal, search, and query.
Debian package tool (dpkg) for package installation, removal, and query.
Redhat packages.
Yellowdog Updater Modified (YUM and DNF) for package installation, removal, search, and query.
Redhat Package Manager (RPM) for package installation, removal, and query
4.2. The purpose of Linux packages¶
All files in Linux distros come in packages. Packages are used for the following tasks:
Install software
Remove software
Update installed software
Fix broken or partly removed software files
Reconfigure installed software
4.3. Linux package management¶
4.4. Ubuntu (Debian) packages¶
Ubuntu OS components and most of the GNU software are available in form of packages. A package file contains:
Software
Info (control) file
Scripts (pre/post install/remove)
md5sum file hashes
Naming convention:
(package-name)_(source version)-(package-version)_(architecture).deb
For example:
make_4.1-9.1ubuntu1_amd64.deb
Package name is make. The source version is 4.1 of GNU Make 4.1 series, package version (revision): 9.1ubuntu1, architecture: amd64.
The official Ubuntu distribution located in the Ubuntu archive, folder main and Restricted. In folder Restricted, there are packages with restricted vendor licensing, for example, nvidia-361.
Universe Is free software available from the network, but not officialy maintained by Ubuntu development team. For example, a2ps (“Anything to PS”), xemacs21. No guarantee of security fixes and support.
Multiverse Packages in the archive have some onerous license condition restricting use or redistribution of the software. For example, dvd-slideshow.
Developers may offer their own package repositories, called package personal archives (PPA).
You can run synaptic package manager to see what package belongs to what folder:
sudo -s
synaptic
Click on Origin to see the folders in the top left window and their packages in the top right one.
4.5. Installing Ubuntu packages with APT (Exercises)¶
Start kvm2 VM and login to its console via virsh:
virsh start kvm2
virsh console kvm2
Try executing command make, which doesn’t exist on the VM yet:
make
The system error comes: The program ‘make’ is currently not installed.
You can install it by typing: sudo apt-get install make Install recommended package make by running apt-get install:
apt-get install make
You should be able to run command make now.
Simulate package installation by using option -s:
apt-get install -s netpbm
Notice the prerequisite library package that would get installed, libnetpbm10 Download the package without installation:
apt-get install -d netpbm
Notice the deb files with the packages in the apt cache directory:
ls -l /var/cache/apt/archives
Install the package:
apt-get install netpbm
Updating all the installed packages
apt-get update
apt-get upgrade
The APT repository and software folders are defined in file
/etc/apt/sources.list
and optionally in directory /etc/apt/sources.list.d
4.6. Removing Ubuntu packages with APT (Exercises)¶
Remove package make by running apt-get remove:
apt-get remove make
Simulate package removal by using option -s:
apt-get remove -s netpbm
Notice package libnetpbm10 won’t be removed Simulate package removal with the dependencies:
apt-get autoremove -s netpbm
Notice the both packages would be removed. Remove the package with the dependencies:
apt-get autoremove netpbm
Both netpbm and libnetpbm10 should be gone now.
4.7. Search and quiry Ubuntu packages with APT (Exercises)¶
First, update the available package list from the Ubuntu repository:
apt-get update
Search for packages containing string make in their name or description:
apt-cache search make
Narrow down the search results for the names containing make:
apt-cache search --names-only make
Filter the output for word make
apt-cache search --names-only make | grep -w ^make
Get the information about package make:
apt-cache show make
List the packages that depend on package make. Forcefully removing make
would break these packages.
apt-cache showpkg make
Show the packages a given package depends on:
apt-cache depends make
4.8. Quiry Ubuntu packages with dpkg (Exercises)¶
What packages are installed on the system?
dpkg -l
Quiry package status with dpkg:
dpkg -s make
dpkg -s tzdata
List the files contained in the package:
dpkg -L tzdata
What package contains a file? For example, command /bin/ls
dpkg -S /bin/ls
Reconfigure a package with command dpkg-reconfigure after installation:
dpkg-reconfigure tzdata
To see the current package configuration, command debconf-show can be used, for example:
debconf-show tzdata
If there is no package dependencies, then a package can be installed with command dpkg. Otherwise, use APT. Install package make:
cp /var/cache/apt/archives/make_4.1-9.1ubuntu1_amd64.deb /tmp
cd /tmp
dpkg -i make_4.1-9.1ubuntu1_amd64.deb
To see the list of the files, contained in the deb package file:
dpkg --contents make_4.1-9.1ubuntu1_amd64.deb
Remove package make by using command dpkg:
dpkg --purge make
4.9. RedHat packages¶
RPM Package naming convention:
(package-name)-(source version)-(package release).(architecture).rpm
For example,
nano-2.3.1-10.el7.x86_64.rpm
Package name is nano. The source version is 2.3.1. The package release is 10.el7 (Release 10 for RedHat Enterprise Linux 7). Architecture is x86_64.
4.10. Installing and removing RedHat packages with YUM (Exercises)¶
Start your CentOS7 VM, login to its console via command virsh console CentOS7, and clean the yum cache:
yum clean all
Install package netpbm on it:
yum install netpbm
Reinstall package netpbm:
yum reinstall netpbm
Install package acpid
yum install acpid
Install YUM utils package:
yum install yum-utils
Now you can run yumdownloader to download packages without installation, for example:
yumdownloader make
ls -l make*
Check available updates for installed packages:
yum check-update
Update package tzdata
yum update tzdata
Updating all the installed packages:
yum update
To remove an installed package:
yum remove netpbm
The same can be accomplished with:
yum erase netpbm
The YUM cache location and configuration are stored in file /etc/yum.conf
The YUM repositores are defined in directory /etc/yum.repos.d/*.repo
4.11. Search and quiry RPM packages with YUM (Exercises)¶
List the installed package and the package available for installation
yum list make
yum list gsl
The former package showes up as installed and the latter as available for installation.
Search for packages containing string make in their name or description:
yum search make
Get the information about package make:
yum info make
List the packages that package make depends upon:
yum deplist make
Install MAN pages:
yum install man
The detailed info on yum can be found in the man pages:
man yum
4.12. Query RPM packages with rpm (Exercises)¶
What packages are installed on the system?
rpm -qa
A friendly readable list comes after sorting the output:
rpm -qa | sort | less
Quiry package status with rpm:
rpm -q make
Display information about the installed package:
rpm -qi make
List the files contained in the package:
rpm -ql make
Which package owns a file? For example, command /bin/ls
rpm -qf /bin/ls
RPM dependencies:
rpm -qR make
If there is no package dependencies or the dependencies have already been resolved, then a package can be simply installed with command rpm from its file. Otherwise, use YUM. Install package make from its rpm file:
rpm -ivh make-3.82-23.el7.x86_64.rpm
It says the package is already installed. Try to remove package make by using command rpm:
rpm -e make
It won’t go because openssl package depends on it.
Quiry a package file, for example:
rpm -qp make-3.82-23.el7.x86_64.rpm
rpm -qlp make-3.82-23.el7.x86_64.rpm
rpm -qip make-3.82-23.el7.x86_64.rpm
The second command above shows the files contained in the package file, and the third command displays the info about the package. More info about command rpm can be found in the man pages:
man rpm
4.13. Deployment of Centos 8.1 appliance (Exercise)¶
On new RedHat systems, #8 and newer, YUM is being replaced with DNF (Dandified Yum). DNF includes all the YUM functionalities and offers more. The syntax is similar in YUM and DNF.
We need to deploy Centos 8.1 VM appliance:
cd KVM
wget http://capone.rutgers.edu/coursefiles/centos8.1.tgz
tar -zxvf centos8.1.tgz
rm centos8.1.tgz
sudo cp centos8.1.xml /etc/libvirt/qemu
virsh define centos8.1.xml
4.14. Installing and removing RedHat packages with DNF (Exercises)¶
Start your centosS8.1 VM, login to its console via command virsh console:
virsh start centos8.1
virsh console centos8.1
Clean the dnf cache:
dnf clean all
Install package netpbm on it:
dnf install netpbm
Reinstall package netpbm:
dnf reinstall netpbm
Install package acpid
dnf install acpid
You can download packages without installation, for example:
dnf download make
ls -l make*
Check available updates for installed packages:
dnf check-update
Update package tzdata
dnf update tzdata
Updating all the installed packages:
dnf update
To remove an installed package:
dnf remove netpbm
The same can be accomplished with:
dnf erase netpbm
The dnf configuration is stored in file /etc/dnf/dnf.conf
The dnf repositores are defined in directory /etc/yum.repos.d/*.repo
4.15. Search and quiry RPM packages with DNF (Exercises)¶
List the installed package and the package available for installation
dnf list make
dnf list gsl
The former package showes up as installed and the latter as available for installation.
Search for packages containing string make in their name or description:
dnf search make
Get the information about package make:
dnf info make
List the packages that package make depends upon:
dnf deplist make
The detailed info on dnf can be found in the man pages:
man dnf