0% found this document useful (0 votes)
149 views18 pages

Package Management

The document discusses different package management tools available in Ubuntu including apt, aptitude, dpkg, and unattended-upgrades. It provides examples of how to use each tool to install, remove, upgrade, and manage software packages on an Ubuntu system. It also describes how to automatically install security updates using unattended-upgrades.

Uploaded by

Brookti Mulugeta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views18 pages

Package Management

The document discusses different package management tools available in Ubuntu including apt, aptitude, dpkg, and unattended-upgrades. It provides examples of how to use each tool to install, remove, upgrade, and manage software packages on an Ubuntu system. It also describes how to automatically install security updates using unattended-upgrades.

Uploaded by

Brookti Mulugeta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Package Management

• Ubuntu features a comprehensive package


management system for installing, upgrading,
configuring, and removing software.

• In addition to providing access to an organized base


of over 45,000 software packages for your Ubuntu
computer, the package management facilities also
feature dependency resolution capabilities and
software update checking.
• Ubuntu's package management system is derived
from the same system used by the Debian GNU/Linux
distribution.
• The package files contain all of the necessary files,
meta-data, and instructions to implement a
particular functionality or software application on
your Ubuntu computer.
• Debian package files typically have the
extension '.deb', and usually exist in
repositories which are collections of packages
found on various media, such as CD-ROM
discs, or online.
• Packages are normally in a precompiled
binary format; thus installation is quick, and
requires no compiling of software.
• Many complex packages use dependencies.
Dependencies are additional packages required by the
principal package in order to function properly.
• For example, the speech synthesis package festival
depends upon the package libasound2, which is a
package supplying the ALSA sound library needed for
audio playback.
• In order for festival to function, it and all of its
dependencies must be installed. The software
management tools in Ubuntu will do this automatically.
dpkg
• dpkg is a package manager for Debian-based systems.
• It can install, remove, and build packages, but unlike other package
management systems, it cannot automatically download and install
packages or their dependencies. dpkg used to manage locally installed
packages:

• To list all packages installed on the system, from a terminal prompt type:
• dpkg –l

• Depending on the amount of packages on your system, this can generate


a large amount of output.
• Pipe the output through grep to see if a specific package is installed:
• dpkg -l | grep apache2
• Replace apache2 with any package name, part of a package name, or
other regular expression.
• To list the files installed by a package, in this case the ufw package, enter:
• dpkg -L ufw
• If you are not sure which package installed a file, dpkg -S may be able to
tell you.
• For example: dpkg -S /etc/host.conf
• base-files: /etc/host.conf

• The output shows that the /etc/host.conf belongs to the base-files


package.
• Many files are automatically generated during the package install process,
and even though they are on the file system.
• dpkg -S may not know which package they belong to.
• You can install a local .deb file by entering:
• sudo dpkg -i zip_3.0-4_i386.deb
• Uninstalling a package can be accomplished by:
• sudo dpkg -r zip
• Uninstalling packages using dpkg, in most cases, is NOT
recommended.
• It is better to use a package manager that handles
dependencies to ensure that the system is in a consistent
state.
• For example using dpkg -r zip will remove the zip package,
but any packages that depend on it will still be installed and
may no longer function correctly.
• For more dpkg options see the man page: man dpkg.
Apt
• The apt command is a powerful command-line tool,
which works with Ubuntu's Advanced Packaging Tool

• (APT) performing such functions as installation of new


software packages, upgrade of existing software
packages, updating of the package list index, and even
upgrading the entire Ubuntu system.

• Being a simple command-line tool, apt has numerous


advantages over other package management tools
available in Ubuntu for server administrators.
• Some of these advantages include ease of use over simple terminal
connections (SSH), and the ability to be used in system administration
scripts, which can in turn be automated by the scheduling utility.

• Some examples of popular uses for the apt utility:


• Install a Package: Installation of packages using the apt tool is quite
simple.
• For example, to install the
• network scanner nmap, type the following:
• sudo apt install nmap

• Remove a Package: Removal of a package (or packages) is also


straightforward. To remove the package
• installed in the previous example, type the following:
• sudo apt remove nmap
• Update the Package Index: The APT package index is essentially a
database of available packages from the repositories defined in the
/etc/apt/sources.list file and in the /etc/apt/sources.list.d directory.

• To update the local package index with the latest changes made in
the repositories, type the following:
• sudo apt update

• Upgrade Packages: Over time, updated versions of packages


currently installed on your computer may
become available from the package repositories (for example
security updates).
To upgrade your system, first update your package index as outlined
above, and then type:
• sudo apt upgrade
Aptitude
• Launching Aptitude with no command-line options, will give you a
menu-driven, text-based front-end to the Advanced Packaging
Tool (APT) system.
• Many of the common package management functions, such as
installation, removal, and upgrade, can be performed in Aptitude
with single-key commands, which are typically lowercase letters.
• Aptitude is best suited for use in a non-graphical terminal
environment to ensure proper functioning of the command keys.
• You may start the menu-driven interface of Aptitude as a normal
user by typing the following command at a terminal prompt:
• sudo aptitude
• Using Aptitude for package management is
relatively straightforward, and the user
interface makes common tasks simple to
perform.
• The following are examples of common
package management functions as performed
in Aptitude:
• Install Packages: To install a package, locate the package via the Not Installed Packages
package category, by using the keyboard arrow keys and the ENTER key. Highlight the
desired package, then press the + key.
• The package entry should turn green, indicating that it has been marked for installation.
Now press g to be presented with a summary of package actions. Press g again, and
downloading and installation of the package will commence. When finished, press
ENTER, to return to the menu.

• Remove Packages: To remove a package, locate the package via the Installed Packages
package category, by using the keyboard arrow keys and the ENTER key. Highlight the
desired package you wish to remove,
then press the - key. The package entry should turn pink, indicating it has been marked
for removal.
• Now press g to be presented with a summary of package actions. Press g again, and
removal of the package will commence. When finished, press ENTER, to return to the
menu.
• Update Package Index: To update the package index, simply
press the u key. Updating of the package index will
commence.
• Upgrade Packages: To upgrade packages, perform the update
of the package index as detailed above,
and then press the U key to mark all packages with updates.
• Now press g whereby you'll be presented with a summary of
package actions.
• Press g again, and the download and installation will
commence.
• When finished, press ENTER, to return to the menu.
• The first column of information displayed in the package list in
the top pane, when actually viewing packages lists the current
state of the package, and uses the following key to describe the
state of the package:
– i: Installed package
– c: Package not installed, but package configuration remains on system
– p: Purged from system
– v: Virtual package
– B: Broken package
– u: Unpacked files, but package not yet configured
– C: Half-configured - Configuration failed and requires fix
– H: Half-installed - Removal failed and requires fix
Command Line Aptitude

• You can also use Aptitude as a command-line tool, similar to


apt.
• To install the nmap package with all necessary
dependencies, as in the apt example, you would use the
following command:
• sudo aptitude install nmap
• To remove the same package, you would use the command:
• sudo aptitude remove nmap
• Consult the man pages for more details of command line
options for Aptitude.
Automatic Updates
• The unattended-upgrades package can be used to automatically
install updated packages, and can be configured to update all
packages or just install security updates.
• First, install the package by entering the following in a terminal:
• sudo apt install unattended-upgrades
• To configure unattended-upgrades, edit /etc/apt/apt.conf.d/50
unattended-upgrades and adjust the following to fit your needs:
• Unattended-Upgrade::Allowed-Origins {
"Ubuntu xenial-security";
// "Ubuntu xenial-updates";
}

You might also like