Linux Package Management

Linux Package Management

Package management is a system by which software can be installed, updated, queried or removed from a filesystem. In Linux, there are many different software package management systems, but the two most popular are those from Debian and Red Hat. The virtual machines for this course use Ubuntu, a derivative of Debian.

At the lowest level of the Debian package management system is the dpkg command. This command can be tricky for novice Linux users, so the Advanced Package Tool, apt-get, a front-end program to the dpkg tool, makes management of packages even easier. Note: Many of the package management commands require administrative access, so they will be prefaced with the sudo command.

Installing Packages

Package files are commonly installed by downloading them directly from repositories located on Internet servers. The Debian repositories contain more than 65,000 different packages of software. Before installing a package, it is good practice to use the refresh the list of available packages using the apt-get update command.

sudo apt-get update

To search for keywords within these packages, you can use the apt-cache search command.

apt-cache search [keyword]

The keyword that is used should match part of the name or description of the package that is to be located. Multiple keywords can be used to further clarify the search; for example, the search term web server would provide better results than web or server. To find packages associated with the cow keyword:

Once you’ve found the package that you want to install, you can install it with the apt-get install command:

sudo apt-get install [package]

Updating Packages

The apt-get install command can also update a package, if that package is installed and a newer version is available. If the package is not already on the system, it would be installed; if it is on the system, it would be updated. Updating all packages of the system should be done in two steps. First, update the cache of all packages available with apt-get update. Second, execute the apt-get upgrade command and all packages and dependencies will be updated.

apt-get update

apt-get update

Removing Packages

The apt-get command is able to either remove or purge a package. The difference between the two is that purging deletes all package files, while removing deletes all but the configuration files for the package. An administrator can execute the apt-get remove command to remove a package or the apt-get purge command to purge a package completely from the system.

apt-get remove [package]

apt-get purge [package]

For example, to purge cowsay completely, execute the following command. Enter Y when prompted:

Leave a Reply
Your email address will not be published. *