Linoob’s Guide to ‘Dpkg’ – Debian Package Manager


Many of us who regularly use terminal often have used ‘dpkg‘ for program installation and removal. ‘dpkg’ is basically a debian package manager that is used to install/remove Debian packages in Ubuntu as well as in Debian. dpkg itself is a low level tool; higher level tools, such as Advanced Pacakging Tool – APT, are used to fetch packages from remote locations or deal with complex package relations. Tools like ‘Aptitude‘ or ‘Synaptic package manager’ are more commonly used than dpkg on its own, as they have an easier way of managing packages and have a user interface.

Basics

Package Installation & Removal

sudo dpkg –i <filename.deb>

Installs the given .deb file.

sudo dpkg -i *<filename.deb>

Installs all the .deb files present in the current directory being accessed.

sudo dpkg –r <package_name>

Removes the given package from the system, but leaves files behind.

sudo dpkg –P <package_name>

Removes package and configuration files of the given package. (purge)

NOTE: <file.deb> and <package_name> should be replaced by actual file & package names.

Simple Example

Lets suppose you downloaded Ubuntu Tweak and you are trying out dpkg. All you need to do is to locate the downloaded file, reach the directory throught terminal and hit the install command.

wget http://launchpad.net/ubuntu-tweak/0.6.x/0.6.1/+download/ubuntu-tweak_0.6.1-1~oneiric1_all.deb /home/Downloads
cd Downloads
sudo dpkg -i ubuntu-tweak_0.6.1-1~oneiric1_all.deb

and that’s it.

File Extraction

sudo dpkg -x <file.deb > <directory>

Extracts the files inside  the .deb file to a destination directory. Note that this will reset permissions on the target directory.

Package Checks

dpkg –l

Lists installed packages. This can also be used to take options for more specific info.

dpkg -L <package_name>

Lists all the files which have been installed from package (package must have been previously installed).

dpkg -c < filename.deb >

Lists files which are installed by the .deb file given (.deb file must be path/filename).

dpkg –I < filename.deb >

Lists information about the .deb given file.

dpkg –p <package_name>

Lists information about the package.

dkpg –S <filename>

Lists the packages where the given file name is found.

dpkg –s <package_name>

Lists the status of the given package.

NOTE : <filename> & <package_name> should be replaced by actual filenames and package names as done in the example.

Njoy !

 


About Cell aka Abhishek

A Technology Fanatic, Open-source lover, a future Entrepreneur, & an Innovative thinker, is presently working as a R&D Engineer in the Wind Turbine Industry.