Introduction
============
In this post, we will discuss the 2 common package
managers in Linux.
They are the following:
1. RPM-based - rpm,yum
2. Debian-based -
dpkg,apt-get,dselect,aptitude,apt-cache
RPM
===
Examples of systems that uses RPM-based package
managers are Red Hat, Fedora,
and Centos. The "rpm" command is to install
packages directly. It doesn't handle
dependency requirements so you need to install the
needed packages (if there is
any) before installing the package you want. For
example, if you want to install
packageA but it needs packageB, you need to install
packageB first before
proceeding with packageA. Here are the common uses of
"rpm" command.
Installing/
Upgrading
|
# installs a package (install only if it doesn't
exist)
rpm -i
# same as the above, but increases verbosity (-v)
and hashes as progress
# indicator (-h)
rpm -ivh
# installs a package even if it exists (package
reinstall)
rpm -ivh
# freshens a package (upgrade a package if ONLY an
older version exists)
rpm -Fvh
# installs a package if that doesn't exist or
upgrade a package if it
# exists
rpm -Uvh
# installs a package ignoring dependency checking
(use this with caution
# because the program you will install might not
work)
rpm -ivh
# do a dry-run instead of installing actual package
rpm -i
|
Removing
|
# removes a package
rpm -e
|
Querying
|
# queries a package (-q) by printing information
(-i); takes only
# package name and not filename (file.rpm)
rpm -qi
# lists files associated in the package (-l)
rpm -ql
# shows you on what package the
file/directory/script came from; example
# is rpm -qf $(which cp)
rpm -qf
# prints change log of the given package
rpm -qi
# prints scripts that ran when the package was
installed
rpm -qi
# queries a package filename instead (-p) of package
name; example is
# rpm -qip my-program.rpm
rpm -q[other query options]p file_name.rpm
|
YUM
===
There is also an RPM-based tool that handles
dependency conflicts automatically
and that is YUM (Yellowdog Updater Modified).
"yum" command is the one we used
which can also do what "rpm" command can.
This is the best package management
tool to use if you are using the Linux distributions
mentioned above.
The main disadvantage of this is you need a repository
before you can do any
transactions whereas RPM don't. Repositories are the
ones inside
/etc/yum.repos.d directory and will be discussed on a
separate post in this
blog. YUM commands that are commonly used are:
Installing/
Upgrading
|
# installs a package or multiple packages
yum install
# same as above but answers "y" to all
installation questions
yum install
# updates all installed packages on the system
yum update
# updates a single or multiple packages
yum update
# installs a local rpm file using your yum
repository to resolve
# dependencies
yum localinstall
|
Removing
|
# removes packages and all packages where the
package depends on
yum remove
# same as above
yum erase
|
Querying
|
# lists all installed packages
yum list
# searches all package names that contains the
string; prints both
# installed and available packages
yum search *pattern*
# deeper search compare to the above command
(searches also contents not
# only package names)
yum search all *pattern*
# shows what package owns the file/directory
yum provides
# use this when you don't get a result from the
above command
yum whatprovides */
# shows info on a package (similar to rpm -qi)
yum info
# checks whether there are updates available
yum check-update
|
DPKG
====
Aside from RPM-based systems, we also have
Debian-based systems. Examples of
these are Ubuntu and of course Debian. The package
management tools they use are
apt-get, aptitude, dselect, and dpkg.
"apt-get" is similar to yum where you need
a repository which is defined under
/etc/apt/sources.lst, "dpkg" is similar to
rpm, "dselect" is a menu based tool, and
aptitude is a combination of dselect's
menu based and apt-get's cli features. Debian packages
by convention ends with
.deb. Let's start with dpkg. Here are the common
commands for dpkg.
Installing/
Upgrading/
Configuring
|
# installs a package
dpkg -i
# ignore dependency conflict (similar to --nodeps in
rpm)
dpgk -i
# tests for dependency only (similar to --test in
rpm)
dpkg -i
# doesn't install a package if a newer version of
same package is
# already installed
dpkg -iG
# doesn't install a package if same version of
package is already
# installed
dpkg -iE
|
Removing
|
# removes a package while retaining its
configuration files
dpkg -r
# removes a package and configuration files
dpkg -P
|
Querying
|
# displays information about an installed package
dpkg -P
# displays information about an uninstalled package
dpkg -I
# displays current installed packages
dpkg --get-selections
# list installed packages matching the pattern
string
dpkg -l
# lists files associated with the package (similar
to rpm -ql)
dpkg -L
|
One command that is very useful if you want to return
the package to its
original state (fresh install with default settings)
is "dpkg-reconfigure".
For example, the command below will reconfigure the
samba package, asking the
packages initial installation questions and restarting
its daemons.
dpkg-reconfigure samba
APT-GET
=======
Similar to yum , Debian-based systems have the tool
called "apt-get" which
automatically handle dependency conflicts. Before
using it, make sure you have
the appropriate sources inside /etc/apt/sources.lst.
Here are the common usage
of that command:
Installing/
Upgrading
|
# installs a package
apt-get install
# installs a package assuming "y" to all
questions
apt-get install
# don't upgrade a package if an older version exists
apt-get install
# downloads a package but doesn't install it
apt-get install
# performs a simulation/dry-run without installing
any package or
# configuring any file
apt-get install
# obtains information on available packages inside
/etc/apt/sources.lst
apt-get update
# upgrades all installed packages to newer versions
apt-get upgrade
# similar to above command but performs
"smart" conflict resolution
apt-get dist-upgrade
|
Removing
|
# removes a package
apt-get remove
|
Configuring
|
# performs any changes in package status left undone
after running
# deselect
apt-get dselect-upgrade
# performs housekeeping (like yum clean)
apt-get clean
# similar to the above command but removes about
packages that can no
# longer be downloaded
apt-get autoclean
|
Querying
|
# checks package database for consistency and broken
package
# installations
apt-get check
|
APT-CACHE
=========
We also have apt-cache. Its only purpose is to provide
information about Debian
package database. Here are sample commands:
Listing
|
# displays information about a package
apt-cache showpkg
# displays package statistics (how many installed,
dependencies recorded
# etc..)
apt-cache stats
# displays information about unmet dependencies
apt-cache unmet
# shows on what packages the one you specified
depend on
apt-cache depends
# displays all installed packages
apt-cache pkgnames
# displays list of installed packages matching the
string specified
apt-cache pkgnames
|
DSELECT
=======
A menu-based package manager also exists for
Debian-based systems. That is
"dselect". When invoked, it will display you
the following menu.
0. [A]ccess Choose the access method to use.
1. [U]pdate Update list of available packages, if
possible.
2. [S]elect Request which packages you want on your
system.
3. [I]nstall Install and upgrade wanted packages.
4. [C]onfig Configure any packages that are
unconfigured.
5. [R]emove Remove unwanted software.
6. [Q]uit Quit dselect.
APTITUDE
========
A tool that combines dselect's menu based gui and
apt-get's cli is "aptitude".
Here are the common usage:
Listing/
Querying
|
# searches packages related to the one you
# NOTE: (apt-get seems not to have this feature
aptitude search
# update package list from APT repository
aptitude update
# shows complete options
aptitude help
|
Installing/
Upgrading
|
# installs a package
aptitude install
# upgrades all installed packages
aptitude full-upgrade
# conservative version of the above command
aptitude safe-upgrade
# removes already-downloaded packages that are no
longer available
aptitude autoclean
|
Removing
|
# removes a package (w/ leading dash)
aptitude install
# same as above
aptitude remove
|
No comments:
Post a Comment