CertCities.com -- The Ultimate Site for Certified IT Professionals
Keep on Top of the Latest Certification News: Subscribe to CertCities.com Newsletter Share share | bookmark | e-mail
  Microsoft®
  Cisco®
  Security
  Oracle®
  A+/Network+"
  Linux/Unix
  More Certs
  Newsletters
  Salary Surveys
  Forums
  News
  Exam Reviews
  Tips
  Columns
  Features
  PopQuiz
  RSS Feeds
  Press Releases
  Contributors
  About Us
  Search
 

Advanced Search
  Free Newsletter
  Sign-up for the #1 Weekly IT
Certification News
and Advice.
Subscribe to CertCities.com Free Weekly E-mail Newsletter
CertCities.com

See What's New on
Redmondmag.com!

Cover Story: IE8: Behind the 8 Ball

Tech-Ed: Let's (Third) Party!

A Secure Leap into the Cloud

Windows Mobile's New Moves

SQL Speed Secrets


CertCities.com
Let us know what you
think! E-mail us at:



 
 
...Home ... Editorial ... Columns ..Column Story Saturday: April 5, 2014


 Inside the Kernel  
Emmett Dulaney
Emmett Dulaney


 Working with Debian Packages
As discussed last month, most software packages for Linux are distributed in one of two special file formats: Red Hat Package Manager (RPM) files or Debian (DEB) files. While the previous month focused on working with RPM files, this one spotlights the format and tools used with DEB files.
by Emmett Dulaney  
5/7/2010 --

As discussed last month, most software packages for Linux are distributed in one of two special file formats: Red Hat Package Manager (RPM) files or Debian (DEB) files. While the previous month focused on working with RPM files, this one spotlights the format and tools used with DEB files.

Debian packages with .deb file extensions store executable files together with configuration files, online documentation, and other information. You can unpack and manipulate these DEB files using the Debian utility dpkg, which is a command-line program that takes many options. A text mode, menu-driven program called dselect is also available for you to manage the packages without having to type dpkg commands. More commonly, you can use a higher-level utility called APT (Advanced Packaging Tool) to work with packages in Debian. For example, instead of downloading a DEB file and installing it with the dpkg command, you can simply use the apt-get command to install the package. The apt-get command can even download the package from an online Debian repository and install it on your system. The dpkg command is still useful when you want to look at the contents of a DEB file that you have manually downloaded from a repository or that might be in the APT cache directory (/var/cache/apt/archives in Debian).

Understanding DEB filenames
A typical DEB package has a filename of the following form:
mozilla-firefox_1.0.4-2_i386.deb

The filename has three parts separated by underscores (_):

Package name: mozilla-firefox
Version and Revision: 1.0.4-2 (Version has two parts separated by a dash. The first part is the package maintainer's version number; the second part is the Debian revision number.)
Architecture: i386. (The package is for Intel x86-compatible systems.)
The filename has a .deb extension, which indicates that this is a DEB file.

Using the dpkg command
To get a feel for the dpkg command, type dpkg --help | more. The output shows the large number of options that dpkg accepts. You can also type man dpkg to read the online man page for dpkg.

You can use dpkg to perform a whole lot of operations on packages, but you have to work at a shell prompt in a terminal window or a text console. The format of a dpkg command is

dpkg [options] action package

with zero or more options, an action indicating what dpkg has to do, and the name of a package, a DEB file or a directory (depends on the action argument). Sometimes the dpkg command does not need any name of package or file, just an action.

Here are some examples of actions you can perform with dpkg:

Install a package from a DEB file with the command dpkg -i packagefile, where packagefile is the name of the DEB file (for example, vsftpd-*.deb).
Remove a package but retain the configuration files with the command dpkg -r packagename, where packagename is the name of the package
Configure a package with the command dpkg --configure packagename, where packagenameis the name of a package
Purge - remove everything including the configuration files - with the command dpkg -P packagename
Audit packages (and find the ones that are partially installed on your system) with the command dpkg -C (does not need a file or package name)
List contents of a DEB file with the command dpkg -c packagefile, where packagefile is the name of the DEB file (for example, vsftpd-*.deb)
View information about a DEB file with the command dpkg -I packagefile
List packages matching pattern with the command dpkg -l pattern, where pattern is the package name pattern - usually with wildcard characters - that you want to match (for example, kernel*)
Find packages that contain files with the command dpkg -S pattern, where pattern is the filename pattern - usually with wildcard characters - that the package contains (for example, stdio*)
List files installed from a package with the command dpkg -L packagename, where packagename is the name of a package

You can try these commands out on a Debian system or any system that uses DEB packages. For example, to look for all packages matching names that begin with mozilla, type dpkg -l mozilla* in a terminal window. Here is the relevant portion of this command's output on a Debian system:

||/ Name                Version        Description
+++-==============-==============-============================================
un mozilla (no description available)
un mozilla-bonobo (no description available)
ii mozilla-browse 1.7.8-1 The Mozilla Internet application suite - cor
ii mozilla-firefo 1.0.4-2 lightweight web browser based on Mozilla

The ii in the first column indicates that the package is installed; un means the package is not installed.
Another common use of dpkg -l is to list all packages and use grep to find lines that match a search string. For example, to find anything containing kernel, type dpkg -l | grep kernel. If the package names (in the second column of the dpkg -l output) are truncated, adjust the width of the output lines with a command like this:

COLUMNS=132 dpkg -l | grep kernel

TIP: The dpkg -S command is a handy way to locate which package provided a specific file in the system. For example, if you want to figure out what package includes the /etc/host.conf file, type dpkg -S /etc/host.conf and the output shows that the base-files package contains /etc/host.conf:

base-files: /etc/host.conf
Introducing dselect
The dselect is meant to be a front-end to the dpkg utility. To try out dselect, log in as root and type dselect in a terminal window (or a text console). When dselect starts, you get the text mode menu.

dselect is not described in detail, but here are some of the tasks you can perform from the dselect main menu:

*  Specify an access method - how to find the DEB packages
*  Update the list of available packages
*  View the status of installed and available packages
*  Select packages and manage dependencies among packages
*  Install new packages or upgrade existing ones to newer versions
*  Configure packages that are not yet configured
*  Remove packages

One common sequence in dselect is to update the list of available packages and then upgrade all packages for which updates are available. You can, of course, perform that same task with a simple APT command as well.

Using APT to manage DEB packages
APT is truly an advanced utility for keeping your Debian system up to date. You can use a number of APT utilities to manage DEB packages. The two commonly used commands are apt-get and apt-cache.

To install a package with apt-get, simply type apt-get install packagename, where packagename is the name of the package that you want to install. For example, to install the vsftpd package, type apt-get install vsftpd.

Removing a package is equally simple. Type apt-get remove packagename, where packagename is the name of the package you want to remove.

If you want to find the name of a package and you know some terms asso­ciated with the package, you can look for it with the apt-cache utility. For example, to look for a CD/DVD burner package, type apt-cache search burn | more to search through the APT's package cache (which is the list of Debian packages that APT downloads from the servers listed in the /etc/apt/sources.list file). Here are some lines of output from that command:

  arson - KDE frontend for burning CDs
  burn - Command line Data-CD, Audio-CD, ISO-CD, Copy-CD writing  tool
  caca-utils - text  mode graphics utilities
  cdcontrol - A parallel burner that allow you to write to one or  more CD-Writers at once
   cdlabelgen - generates front cards and tray cards for CDs and  DVDs
  cdrtoaster - Tcl/Tk front-end for burning cdrom
  cdw - Tool for burning CDs - console version
  cdw-common - Tool for burning CDs - common files
  cpuburn - a collection of programs to put heavy load on CPU
  cwcdr - Chez Wam CD Ripper
  dvd+rw-tools - DVD+-RW/R tools
  dvdbackup - tool to rip DVDs from the command line
  edenmath.app - Scientific calcualtor for GNUstep
  gcdw - Tool for burning CDs - graphical version
  gcombust - GTK+ based CD mastering and burning program
  ... lines deleted ...
The output shows several potential CD/DVD burning programs that could be installed. To discover more about any of the packages, type apt-cache show packagename, where packagename is the name of the package for which you want information. For example, to find out more about the dvd+rw-tools package, type apt-cache show dvd+rw-tools and the output shows a description of the package. You can then install the package with apt-get install.

TIP: To search for a keyword that appears in the package's name only, use the --names-only option like this: apt-cache search - -names-only keyword, where keyword is something that appears in the package's name. For example, if you want to find packages that contain selinux in their names, type apt-cache search - -names-only selinux.

You can run apt-get clean periodically to clean out the local repository (in the /var/cache/apt/archives directory) of DEB files that have already been installed. In doing this, you can free up some disk space by removing these DEB files.

Just as last month, this is not a complete list of what can be done with DEB files, but should give you a good understanding of their potential.


Emmett Dulaney is the author of several books on Linux, Unix and certification. He can be reached at .

 


More articles by Emmett Dulaney:

-- advertisement --


There are 14 CertCities.com user Comments for “Working with Debian Packages”
Page 1 of 2
4/27/11: Cactus from igEhUrWrxVJH says: That's 2 clever by half and 2x2 clever 4 me. Thnaks!
1/6/13: louis vuitton store from [email protected] says: Thank you for some other excellent article. Where else could anybody get that type of information in such an ideal approach of writing? I have a presentation next week, and I'm on the search for such information. louis vuitton store http://louisvuittonstores2013.overblog.com
7/1/13: louis vuitton outlet store from [email protected] says: good share. louis vuitton outlet store http://www.louisvuittonttoutlet.com
7/4/13: guccioutletstore-online.com from [email protected] says: nice articles guccioutletstore-online.com http://www.guccioutletstore-online.com
7/26/13: Discount Christian Louboutin Shoes from [email protected] says: thank you for share! Discount Christian Louboutin Shoes http://www.discount-louboutin.net/
8/30/13: customized nfl jerseys from [email protected] says: thanks for share! customized nfl jerseys http://www.customnflljerseys.com
9/1/13: michael kors outlet coupons from [email protected] says: thanks for share! michael kors outlet coupons http://www.michaelkorseoutlet.org/
9/5/13: moncler sale from [email protected] says: thanks for share! moncler sale http://www.moncleresale.org
9/5/13: best teams in the nfl from [email protected] says: good articles best teams in the nfl http://www.bestnflluniforms.com
9/13/13: moncler jackets sale from [email protected] says: thanks for share! moncler jackets sale http://www.moncleresale.org
First Page   Next Page   Last Page
Your comment about: “Working with Debian Packages”
Name: (optional)
Location: (optional)
E-mail Address: (optional)
Comment:
   

-- advertisement (story continued below) --

top