Never Ending Security

It starts all here

Tag Archives: Dpkg

Practical dpkg commands for Linux

Practical dpkg

Debian GNU/Linux, the mother of all Operating Systems uses one of the most widely used Package Manager: dpkg

Install a Package

To install a “.deb” package, use the command with “-i” switch

[]# dpkg -i <packet>.deb

List all installed packages

To view and list all installed packages, use the “-l” switch

[]# dpkg -l

To view information about specific package use the option “-l” along with package name

[]# dpkg -l apache2

Remove a Package

To remove a “.deb” package, you must specify the package name after “-r” switch

[]# dpkg -r <package>

You can also use ‘p‘ option in place of ‘r’ which will remove the package along with configuration file. The ‘r‘ option will only remove the package and not configuration files.

What’s Inside ?

To view the content of a particular package, use the “-c” switch.

[]# dpkg -c <package>.deb
drwxr-xr-x root/root         0 2012-12-14 22:54 ./
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/bin/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/lib/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/
drwxr-xr-x root/root         0 2012-12-14 22:54 ./usr/share/man/

Is It Installed ?

Using “-s” switch with the package name will display whether that package is installed or not.

[]# dpkg -s package

Where are you going with that ?

To list location where the files will be installed

[]# dpkg -L <package>

Install All The Things !!!

Recursively install all “*.deb” packages found in a directory and all of its subdirectories

[]# dpkg -R --install testdir/(

Let’s Just unPack First

Using switch “–unpack” will unpack the package but it will not perform install or configure.

[]# dpkg --unpack <package>.deb

I Messed Up

The switch “–configure” will reconfigure a already unpacked package.

[]# dpkg --configure <package>

Replace Package Information

The “–-update-avail” switch replace the old information with the available information in the Packages file.

[]# dpkg –-update-avail <package>

Erase !

The switch “–clear-avaial” will erase the current information about what packages are available.

[]# dpkg –-clear-avail

Forget ?!

The dpkg command with switch “–forget-old-unavail” will automatically forget uninstalled and unavailable packages .

[]# dpkg --forget-old-unavail

Display Licence

[]# dpkg --licence

Display Version

The “–version” switch will display dpkg version information.

[]# dpkg –version

Get all the Help !!!

The “–help” option will display a list of available options of dpkg command.

[]# dpkg –help
Usage: dpkg [<option> ...] <command>

  -i|--install       <.deb file name> ... | -R|--recursive <directory> ...
  --unpack           <.deb file name> ... | -R|--recursive <directory> ...
  -A|--record-avail  <.deb file name> ... | -R|--recursive <directory> ...
  --configure        <package> ... | -a|--pending
  --triggers-only    <package> ... | -a|--pending
  -r|--remove        <package> ... | -a|--pending
  -P|--purge         <package> ... | -a|--pending
  --get-selections [<pattern> ...] Get list of selections to stdout.
  --set-selections                 Set package selections from stdin.
  --clear-selections               Deselect every non-essential package.
  --update-avail <Packages-file>   Replace available packages info.
  --merge-avail <Packages-file>    Merge with info from file.
  --clear-avail                    Erase existing available info.
  --forget-old-unavail             Forget uninstalled unavailable pkgs.
  -s|--status <package> ...        Display package status details.