Ubuntu – dpkg and apt-get beginner tutorial

Installing and managing packages is the first thing you do when you use any Linux system. It takes a while to get hang of it on Ubuntu Linux. Here are the the package management commands which I use frequently to manage packages on Ubuntu:

Find latest version of a package

Install (dryrun) memcached using apt-get. Use -s (silent) or --dry-run. This way we can find the latest version available without installing it.

sudo apt-get install --dry-run memcached

Or you can also use apt-cache policy

$ sudo apt-cache policy phantomjs

Install a package on Ubuntu

Install memcached using apt-get

sudo apt-get install memcached

Resynchronize the package index files from their sources

sudo apt-get update

Upgrade the newest versions of all installed packages

sudo apt-get upgrade

Upgrade a specific package

Upgrade php-apc using apt-get

sudo apt-get --only-upgrade install php-apc

Remove a package

Remove memcached using apt-get

sudo apt-get remove memcached

List all packages on your system

sudo dpkg -l

List all files for a package (e.g. apache2)

sudo dpkg -L apache2

File package(s) owning a file (or files)

To list package for /etc/apache2/apache2.conf
dpkg -S /etc/apache2/apache2.conf

apache2.2-common: /etc/apache2/apache2.conf
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments