Sunday, June 20, 2010

Debian: How to Install or Remove DEB Packages Using dpkg

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

No comments:

Post a Comment