Package repositories

Update the package repositories from sources with the latest versions

sudo apt-get update

A list of repositories, that the server will check for packages, is stored at /etc/apt/sources.list

cat /etc/apt/sources.list

Extra repositories can be added to /etc/apt/sources.list.d

Package information

Search for available packages (eg. mysql); to search only by the package name, use -n tag.

sudo apt-cache search mysql
sudo apt-cache search -n mysql

Get the package information (eg. mysql-server-5.6)

sudo apt-cache show mysql-server-5.6

Install/uninstall a package

Install a package || without prompting use tag -y || for quiet install use tag -qq

sudo apt-get install -y mysql-server-5.6

Uninstall a package ('purge' removes the configuration, 'remove' removes only the package)

sudo apt-get purge mysql-server-5.6

After uninstalling use autoremove to remove any dependencies that are not in use by other packages

sudo apt-get autoremove

List all installed packages

Get a list of packages installed locally (the -v tag "inverts" grep to return non-matching lines)

dpkg --get-selections | grep -v deinstall

Get a list of a specific package installed

dpkg --get-selections | grep mysql

Alternatively, simply use

dpkg -l

Get just the packages which were expressly installed (not just installed as dependencies)

aptitude search '~i!~M'