Ubuntu Package Management
Chances are good that you’re already familiar with apt-get, a command which uses the “advanced package tool” to interact with the operating system’s underlying package system. The most relevant and useful commands are, (to be run as root):
1 |
apt-get install [package-name] |
This command installs the package(s) specified, along with any dependencies.
1 |
apt-get remove [package-name] |
This command removes the package(s) specified, but does not remove dependencies.
1 |
apt-get autoremove |
This command removes any “orphaned” dependencies which remain installed but are not used by any applications.
1 |
apt-get clean |
Removes downloaded package files (.deb) for software that are already installed.
1 |
apt-get purge [optional] |
Combines the functions of remove and clean for a specific package. Also removes configuration files for the given package.
1 |
apt-get update |
Reads the /etc/apt/sources.list file and updates the system’s database of packages available for installation. Run this after changing sources.list.
1 |
apt-get upgrade |
Upgrades all packages if there are updates available. Run this after running apt-get update.
While apt-get likely provides the most often used functionality of the package management, apt provides additional information that you may find useful in the apt-cache command.
1 |
apt-cache search [package-name] |
If you know the name of a piece of software but apt-get install fails or points to the wrong software, use search to look for other possible names, if you need to find out the name of a package that you know is in the system.
1 |
apt-cache show [package-name] |
The search interface only provides package names. If you need to learn more about a package, including dependency information, version numbers and a basic description, run this.
1 |
apt-cache depends [package name(s)] |
Lists the packages that the specified packages depends upon in a tree. These are the packages that will be installed with the apt-get install command.
1 |
apt-cache rdepends [package name(s)] |
Generates and outputs a list of packages that that depend upon the specified package. This list can often be rather long.
1 |
apt-cache pkgnames |
Generates a list of the currently installed packages on your system. This list is often rather long, so it is best to pipe its output through a command like less.
Leave a Comment