Package management

It is good to know how to manage packages, because uninstalled ones can leave configuration files behind and there are also many pre-installed packages which you might not need.

=Warning=

The usual warnings apply. You are performing administrating tasks on your device with root account and you can brick your device. If you don't know what are you typing into the terminal, then it is probably for the best if you don't do it at all!

=dpkg=

Install package from a local .deb file:

dpkg -i

List all installed packages:

dpkg -l

List all packages that are not in "normal" (ii ) state:

dpkg -l | awk '$1 != "ii" {print $0}'

This also lists previously uninstalled packages which left config files behind (those will have "rc" state in the first column). You can purge (completely uninstall) them with:

dpkg -P package

If you are unsure, you can check which files were left by a certain package with command:

dpkg -L package

Purging can give you the following errors (read the output!):

1. dpkg - warning: while removing package, directory `/path/dir' not empty so not removed.

It is ok if you manually delete those dirs/files if you know that they belong to the purged package (for example: don't delete /etc).

2. dpkg: error processing package (--purge):

An error occured while removing/purging the package, again resolve it manually.

=apt-get=

Install package from a repository:

apt-get install package

Remove a package:

apt-get remove

Purge a package:

apt-get purge

Update package lists (checks for updates, downloads new list of packages which are in the repository...):

apt-get update

Update packages:

apt-get upgrade

It will display which ones are to be updated and it asks you if you want to proceed so this is also the command to show available updates.

This will empty local cache containing downloaded installation packages:

apt-get clean