In few words, package management is a method of installing
and maintaining (which includes updating and probably removing as well)
software on the system.
In the early days of Linux,
programs were only distributed as source code, along with the required man
pages, the necessary configuration files, and more. Nowadays, most Linux
distributors use by default pre-built programs or sets of programs called packages,
which are presented to users ready for installation on that distribution.
However, one of the wonders of Linux is still the possibility to obtain source
code of a program to be studied, improved, and compiled.
if a certain package requires a
certain resource such as a shared library, or another package, it is said to
have a dependency. All modern package management systems provide some method of
dependency resolution to ensure that when a package is installed, all of its
dependencies are installed as well.
Almost all the software that is
installed on a modern Linux system will be found on the Internet. It can either
be provided by the distribution vendor through central repositories (which can
contain several thousands of packages, each of which has been specifically
built, tested, and maintained for the distribution) or be available in source
code that can be downloaded and installed manually.
In order to perform the task of
package management effectively, you need to be aware that you will have two types
of available utilities: low-level tools (which handle in the backend
the actual installation, upgrade, and removal of package files), and high-level tools
(which are in charge of ensuring that the tasks of dependency resolution and
metadata searching -”data about the data”- are performed).
DISTRIBUTION
|
LOW-LEVEL TOOL
|
HIGH-LEVEL TOOL
|
Debian and derivatives
|
dpkg
|
apt-get / aptitude
|
CentOS
|
rpm
|
yum
|
openSUSE
|
rpm
|
zypper
|
dpkg is a low-level package
manager for Debian-based systems. It can install, remove, provide information
about and build *.deb packages but it can’t automatically download and install
their corresponding dependencies.
apt-get is a high-level
package manager for Debian and derivatives, and provides a simple way to
retrieve and install packages, including dependency resolution, from multiple
sources using the command line. Unlike dpkg, apt-get does not work directly
with *.deb files, but with the package proper name.
What is apt-get?
The apt-get utility is
a powerful and free package management command line program, that is used to
work with Ubuntu’s APT (Advanced Packaging Tool) library to perform
installation of new software packages, removing existing software packages,
upgrading of existing software packages and even used to upgrading the entire
operating system.
What is apt-cache?
The apt-cache command
line tool is used for searching apt software package cache. In simple words,
this tool is used to search software packages, collects information of packages
and also used to search for what available packages are ready for installation
on Debian or Ubuntu based systems.
Examples
To list all the available packages, type the following command.
$ apt-cache pkgnames
To find out the package name and
with it description before installing, use the ‘search‘ flag
$ apt-cache search vsftpd
---will display the details of vsftpd.
if you would like to check information of package along with
it short description
$apt-cache show netcat ----will display the details of package netcat
the ‘update‘ command is used to
resynchronize the package index files from the their sources specified in /etc/apt/sources.list file.
The update command fetched the packages
from their locations and update the packages to newer version.
$ sudo apt-get update
The ‘upgrade‘ command is used to
upgrade all the currently installed software packages on the system
$ sudo apt-get
upgrade
The ‘install‘ sub command is tracked by one or more packages
wish for installation or upgrading.
$ sudo apt-get
install netcat --- will install netcat
package
You can add more than one package name along with the
command in order to install multiple packages at the same time. For example,
the following command will install packages ‘nethogs‘ and ‘goaccess‘.
$ sudo apt-get
install nethogs goaccess
Using sub ‘–no-upgrade‘ command will prevent already
installed packages from upgrading.
$ sudo apt-get
install packageName --no-upgrade
The ‘–only-upgrade‘ command do not install new packages but
it only upgrade the already installed packages and disables new installation of
packages.
$ sudo apt-get
install packageName --only-upgrade
To un-install software packages
without removing their configuration files (for later re-use the same
configuration). Use the ‘remove‘ command as shown.
$ sudo apt-get remove vsftpd
To remove software packages including their configuration
files, use the ‘purge‘ sub command as shown below.
$ sudo apt-get purge
vsftpd
The ‘clean‘ command is used to free up the disk space by
cleaning retrieved (downloaded) .deb files (packages) from the local
repository.
$ sudo apt-get clean
To download only source code of particular package, use the
option ‘–download-only source‘ with ‘package-name’ as shown.
$ sudo apt-get
--download-only source vsftpd
To download and unpack source code of a package to a
specific directory, type the following command.
$ sudo apt-get source
vsftpd
You can also download, unpack and compile the source code at
the same time, using option ‘–compile‘ as shown below.
$ sudo apt-get
--compile source goaccess
Using ‘download‘ option, you can download any given package
without installing it. For example, the following command will only download ‘nethogs‘
package to current working directory.
$ sudo apt-get
download nethogs
The ‘check‘ command is a diagnostic tool. It used to update
package cache and checks for broken dependencies.
$ sudo apt-get check
This ‘build-dep‘ command searches
the local repositories in the system and install the build dependencies for
package. If the package does not exists in the local repository it will return
an error code.
$ sudo apt-get build-dep netcat
The ‘autoclean‘ command deletes all .deb files
from /var/cache/apt/archives to free-up significant volume of disk
space.
$ sudo apt-get
autoclean
The ‘autoremove‘ sub command is used to auto remove packages
that were certainly installed to satisfy dependencies for other packages and
but they were now no longer required. For example, the following command will
remove an installed package with its dependencies.
$ sudo apt-get
autoremove vsftpd
Comments
Post a Comment