Debian: How to Install or Remove DEB Packages Using dpkg

by Sasikala on June 18, 2010

Question: I would like to know how to install, uninstall, verify deb packages on Debian. Can you explain me with an example?

Answer: Use dpkg to install and remove a deb package as explained below.

On Debian, dpkg (Debian package system) allows you to install and remove the software packages. dpkg is the simplest way to install and uninstall a package.

Debian now supplies a tool named Apt (for “A Package Tool”) and aptitude to help the administrators to add or remove software more easily. Refer to our earlier Manage packages using apt-get for more details.

Installing a Deb Using dpkg -i

syntax:
dpkg -i package-file-name

-i is to install a package.

The following example installs the Debian package for tcl tool.

$ dpkg -i tcl8.4_8.4.19-2_amd64.deb
Selecting previously deselected package tcl8.4.
(Reading database ... 94692 files and directories currently installed.)
Unpacking tcl8.4 (from tcl8.4_8.4.19-2_amd64.deb) ...
Setting up tcl8.4 (8.4.19-2) ...
Processing triggers for menu ...
Processing triggers for man-db ...

You can verify the installation of package using dpkg -l packagename as shown below.

$ dpkg -l | grep 'tcl'
ii  tcl8.4                               8.4.19-2                   Tcl (the Tool Command Language) v8.4 - run-t

The above command shows that tcl package is installed properly. ‘ii’ specifies status ‘installed ok installed’.

Uninstalling a Deb using dpkg -r

dpkg with -r option removes the installed package.

$ dpkg -r tcl8.4
(Reading database ... 94812 files and directories currently installed.)
Removing tcl8.4 ...
Processing triggers for man-db ...
Processing triggers for menu ...

Now list the package and check the status.

# dpkg -l | grep 'tcl'
rc  tcl8.4                                8.4.19-2                   Tcl (the Tool Command Language) v8.4 - run-t

rc stands for ‘removed ok config-files’. The remove action didn’t purge the configuration files. The status of each installed package will be available in /var/lib/dpkg/status. Status of tcl8.4 package looks like,

Package: tcl8.4
Status: deinstall ok config-files
Priority: optional
Section: interpreters
Installed-Size: 3308

The following command is used to purge the package completely.

$ dpkg -P tcl8.4
(Reading database ... 94691 files and directories currently installed.)
Removing tcl8.4 ...
Purging configuration files for tcl8.4 ...
Processing triggers for menu ...
$ dpkg -l | grep 'tcl'
$

So the package is completely removed, and the status in the /var/lib/dpkg/status is given below.

Package: tcl8.4
Status: purge ok not-installed
Priority: optional
Section: interpreters

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 1 comment… read it below or add one }

1 Rick Stanley June 18, 2010 at 8:13 am

First of all, you should use the ‘man’ command to see the options available for this and most all other applications, tools, etc… in Linux

$man dpkg

dpkg is fine for adding packages not in the Debian package depository, but you should also be aware of apt, yes, but in addition to that CLI tool, you may also be aware of gui tools, aptitude, and synaptic. I have found some problems with apt-get, and have been using the gui alternatives most of the time.

Leave a Comment

Previous post:

Next post: