1. Home
  2. Tutorials
  3. SysAdmin
  4. Debian/Ubuntu APT
Yolinux.com Tutorial

Linux Debian / Ubuntu APT Package Management

Using Debian and Ubuntu dpkg and apt package management for application installation, removal and management.

Debian and Ubuntu package management:

YoLinux admin tux graphic

 

 



Free Information Technology Magazines and Document Downloads
TradePub link image

APT/dpkg - Ubuntu / Debian Package Manager:

dpkg:

Ubuntu/Debian package management. (equivalent to rpm in functionality.)
Command Description
dpkg -l List all packages installed on system. Often used with grep: dpkg -l | grep partial-name-of-package
dpkg -l package-name Show version of package and description if package is installed.
dpkg -L package-name List all files on the system associated with the package.
dpkg -S file-name List the package name to which this file is associated.
dpkg -p file-name Print package information. See /var/lib/dpkg/available
dpkg -i package-name.deb Install package.
Also see "apt-get install package-name".
dpkg -r package-name Remove package. Keep configuration files.
Also see "apt-get remove package-name".
dpkg -P package-name Remove package. Remove configuration files.
Also see "apt-get remove package-name".
dpkg -c package-name.deb List all files to be installed and the proposed installed location.
dpkg -s package-name.deb List status of package (version, description, ....

apt-get:

Ubuntu/Debian package installer using an internet repository. (equivalent to yum in functionality.)
Command Description
apt-get install package-name
apt-get install package-1, package-2
Query repository for package and if package is available, download and install.
apt-get remove package-name Remove package from system. Keeps configuration files. Use flag "--purge" to remove configuration files.
apt-get -s update
or
apt-get --simulate update
Simulate apt-get actions to be taken but no action is performed. In this example, apt-get simulates an update.
apt-get update Update the package index on the system to the latest version associated with the OS release in use. Only the index (package list) is changed. An update should always be performed before an upgrade
apt-get -s upgrade The command will identify all packages to be upgraded without performing an upgrade. Stop any services targeted for upgrade before perfoming the upgrade.
apt-get upgrade Upgrade all packages on the system to the newest versions of all the packages. The command will first identify all packages to be upgraded and then with permission, will perform an upgrade on the packages. Use flag "-y" to grant permission and avoid question.
Typical use:
apt-get update
apt-get upgrade
apt-get dist-upgrade Upgrade the OS and all packages on the system to the newest version. eg upgrade from version 11.10 (Oneiric Ocelot) to 12.04 (Precise Pangolin).
Typical use:
apt-get update
apt-get dist-upgrade
apt-get source package-name Download package source.
apt-get build-dep package-name Configure build-dependencies for source packages.

Uses the configuration file: /etc/apt/apt.conf

Uses the repository source list: /etc/apt/sources.list

deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-updates main restricted

## Uncomment the following two lines to add software from the 'universe'
## repository.
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper universe

## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
#deb http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
#deb-src http://us.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
# deb http://security.ubuntu.com/ubuntu dapper-security universe
# deb-src http://security.ubuntu.com/ubuntu dapper-security universe
    

[Potential Pitfall]: A new installation requires use of the command: apt-get update before apt-get will work.

[Potential Pitfall]: If you add a new repository you must execute the command: apt-get update. Attempting to install a package (apt-get install xxxxxxx) from a new archive without first updating, will give you the following error message:
Package xxxxxxx is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package mplayer has no installation candidate
      
Where "xxxxxxx" is the package you were trying to install.

Other:

Command Description
apt-cache search package-name Query repositories to see if package is available.

Also see the man pages for: dpkg, dselect, apt-get, apt-cache, apt-cdrom (add CD-Rom to sources list), apt-config

Links:

Book imageBooks:

Amazon book image "Ubuntu Unleashed 2017 edition:"
Covering 16.10 and 17.04, 17.10 (12th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0134511182

Amazon.com
Amazon book image "Ubuntu Unleashed 2013 edition:"
Covering 12.10 and 13.04 (8th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0672336243
(Dec 15, 2012)

Amazon.com
Amazon book image "Ubuntu Unleashed 2012 edition:"
Covering 11.10 and 12.04 (7th Edition)
by Matthew Helmke, Andrew Hudson and Paul Hudson
Sams Publishing, ISBN# 0672335786
(Jan 16, 2012)

Amazon.com
Amazon book image "Practical Guide to Ubuntu Linux (Versions 8.10 and 8.04)"
by Mark Sobell
Prentice Hall PTR, ISBN# 0137003889
2 edition (January 9, 2009)

Amazon.com

   
Bookmark and Share

Advertisements