Skip to content.

Package Management for .deb & .rpm for Debian, Ubuntu & Red Hat, CentOS, Suse

A smattering of useful commands for dealing with package managers!


Package manager front-ends are the programs used to use the package manager, for Debian these are apt, apt-get & dpkg; for CentOS these are yum, dnf & rpm.

List all packages

> dpkg -l
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                          Version                                      Architecture Description
ii  accountsservice                               0.6.45-2                                     amd64        query and manipulate user account information
ii  accountwizard                                 4:18.08.3-1                                  amd64        wizard for KDE PIM applications account setup
ii  acl                                           2.2.53-4                                     amd64        access control list - utilities
ii  adduser                                       3.118                                        all          add and remove users and groups
> rpm -qa

List files provided by a package

> dpkg -S inotifywait
inotify-tools: /usr/share/man/man1/inotifywait.1.gz
inotify-tools: /usr/bin/inotifywait
> rpm -ql inotifywait

List enabled repos

> dpkg ...
> yum repolist

Show scriptlets

Packages can run small shell scripts as part of their install and removal.

> dpkg --dry-run -i package.deb ?????
> rpm -qp --scripts package.rpm
postinstall scriptlet (using /bin/sh):
preuninstall scriptlet (using /bin/sh):
postuninstall scriptlet (using /bin/sh):

Update except for …

> apt-mark hold openssl
> apt dist-upgrade
> apt-mark unhold openssl

> yum update --exclude=openssl

Extract files

> dpkg -x package.deb .

> rpm2cpio package.rpm | cpio -idmv

Build process


RPMs are build using rpmbuild on a build directory which is defined by ~/.rpmmacros, some directives being:

  • $_topdir /home/joe/rpmbuild - Where rpmbuild will look for sources and produce RPMs.
  • %_tmppath $_topdir/temp - A location for temporary files, perhaps place it in /tmp/ to ensure it gets cleared.
  • %dist .heaton - This is inserted after the version number to denote the package variant.

The rpmbuild/ directory structure:

    • Axiom
  • RPMS
    • Output completed RPM
    • Files to be packaged in RPM
    • Configuration & scripting for the RPM build
    • Conveniently extract or reproduce an existing RPM from its Source RPM
%define _prefix /usr/local/bin/

Name:        nano
Version:     2.8.6
Release:     1%{?dist}
Summary:     a user-friendly editor, a Pico clone with enhancements

Group:       applications/editors
License:     GPLv3+
Vendor:      GNU Project

Source0:     %{name}-%{version}.tar.xz

BuildRoot:   %{_tmppath}/%{name}-%{version}-buildroot
BuildArch:   x86_64
BuildRequires: autoconf, automake, gettext-devel, ncurses-devel, texinfo

GNU nano is a small and friendly text editor.  It aims to emulate the
Pico text editor while also offering several enhancements.

%setup -q -n %{name}-%{version}

tar -xf "%{SOURCE0}" --strip-components=1




mkdir -p %{buildroot}/opt/ukmo/nano/%{version}
mkdir -p "%{buildroot}/opt/metoffice/modulefiles/nano-%{version}"
%{__install} -m 0644 -D "%{SOURCE1}" "%{buildroot}/opt/metoffice/modulefiles/nano/%{version}"

rm -rf "%{buildroot}"



* Fri Jan 01 2016 Joe Heaton <[email protected]> - 1.2.3-0
- Initial Version
Joe Heaton

Joe’s technology-focused murmurings.
comments powered by Disqus