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.


Contents

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

Remove unneeded dependencies (packages):

apt-get autoremove


Perform a package maintenance

Don't just blindly follow these instructions if you don't know what you're doing. They're more of a guidance...


1. Refresh the repositories (apt-get update in command line).

2. Update applications (apt-get upgrade in command line).

3. Empty local cache with apt-get clean.

4. Remove unneeded dependencies with apt-get autoremove.

5. List all packages that are not in "normal" (ii ) state with dpkg (script is above).

6. Purge them (dpkg -P package).

7. Check if they were any errors from purging and resolve them.