Debian - Apt and Dpkg Commands

by Scott, Revised on February 19, 2016 (Linux)

Apt-get Commands

Update the package list:

apt-get update

Upgrade system:

apt-get upgrade

Upgrade system installing new dependencies:

apt-get dist-upgrade

Install package:

apt-get install package

Remove package:

apt-get remove package

Remove package and purge all files (configs, etc.):

apt-get remove --purge package

Cleans the package cache:

apt-get clean

Cleans the package cache of older versions, keeping the latest:

apt-get autoclean

Search package names and descriptions for entered keywords:

apt-cache search package

List more information about a package:

apt-get show package

Dpkg commands

Install:

dpkg -i long_package_name

Remove:

dpkg -r package

Purge:

dpkg -P package

List version info and status:

dpkg -l package

List files of installed package:

dpkg -L package

List package that contains the file:

dpkg -S file

List installed packages

dpkg -l
dpkg -l | grep postgres*

Tags: Linux