May 19, 2010, 8:23 a.m.
posted by void
Install and Remove Standalone .deb Files
Use command-line tools to install individual .deb files when other automated tools aren't an option. The package management for Debian-based distributions like Ubuntu is very powerful and saves a lot of effort that could be wasted finding the latest packages and tracking down dependencies. Automated tools like apt-get, Synaptic, and Adept should serve most users' needs almost all of the time, and you should stick to those tools whenever possible. However, there are some circumstances when you need to install a .deb package directly.
Install a .debWhatever the reason, when you find yourself with a .deb to install, it's time to turn to dpkg. dpkg is the tool that Debian-based distributions like Ubuntu use to install .deb files. (Even when you use an automated package-management tool, dpkg is used behind the scenes to actually install the packages to the system.) If you are familiar with the rpm tool for RPM-based distributions, you'll find dpkg has similar syntax. To install an ordinary .deb from the command line, type: whiprush@ubuntu:~$ sudo dpkg -i
packagename
.deb
Replace packagename .deb with the .deb file you wish to install. If you have multiple files you want to install at the same time, you can either list them one after another on the command line: whiprush@ubuntu:~$ sudo dpkg -i
package1
.deb
package2
.deb
package3
.deb
or use a file glob [Hack #13] to install all .deb files in the current directory: whiprush@ubuntu:~$ sudo dpkg -i
*.deb
dpkg also has a recursive option (-R). If you have a directory full of debs you want to install, type: whiprush@ubuntu:~$ sudo dpkg -i -R
/path/to/directory
and dpkg will recursively find and install all .deb files within that directory and its subdirectories. Occasionally, when you install a package with dpkg, it might abort because a package is marked hold, it conflicts with another package, it depends on other packages that aren't installed, installing the package would overwrite files from another package, or a number of other reasons. dpkg provides a number of --force options you can use to ignore these problems and proceed with package installation.
To see the complete list of --force options, type: whiprush@ubuntu:~$ dpkg --force-help
Some of the more useful options include:
So if you have a .deb you need to install that overwrites files from another package, and you have done your homework and confirmed that it is OK to proceed, type: whiprush@ubuntu:~$ sudo dpkg -i --force-overwrite
packagename
.deb
Remove a PackageOccasionally, you may need to remove a standalone package manually. dpkg provides the -r and -P options to remove and purge packages, respectively. To remove a package, type: whiprush@ubuntu:~$ sudo dpkg -r
packagename
Note that you don't specify the name of the complete .deb file you might have installed previously, only the name of the package itself. When given the -r option, dpkg will find and remove all of the files for this package except for configuration files, which it leaves behind in case you install the program again. If you want to purge the system of all files, including configuration files, use -P instead: whiprush@ubuntu:~$ sudo dpkg -P
packagename
|
- Comment

