apt-get

apt-get

The apt-get command is a powerful package management tool used in Debian-based Linux distributions, such as Debian, Ubuntu, and their derivatives. It allows users to install, update, upgrade, and remove software packages from the system's repositories.

Basic Commands

Update Package List

Before installing or upgrading packages, you should update the package list to ensure you have the latest information about available packages:

sudo apt-get update

Upgrade Packages

To upgrade all installed packages to their latest versions, use:

sudo apt-get upgrade

To perform a more comprehensive upgrade that may install or remove packages to satisfy dependencies, use:

sudo apt-get dist-upgrade

Install a Package

To install a specific package, use:

sudo apt-get install package_name

For example, to install the curl package:

sudo apt-get install curl

Remove a Package

To remove a specific package, use:

To remove a package along with its configuration files, use:

Clean Up

To remove packages that were automatically installed to satisfy dependencies for other packages and are no longer needed:

To clean the local repository of retrieved package files:

To remove all packages that have been downloaded but are no longer installed:

Advanced Commands

Search for Packages

To search for a package by name or description:

Show Package Information

To display detailed information about a package:

Check for Broken Dependencies

To check for broken dependencies and attempt to fix them:

Download a Package Without Installing

To download a package without installing it:

Upgrade the Distribution

To perform a distribution upgrade, which includes upgrading to a new release of the operating system:

Example Usage

Update and Upgrade

To update the package list and upgrade all installed packages:

Install Multiple Packages

To install multiple packages at once, list them separated by spaces:

Remove Multiple Packages

To remove multiple packages at once:

Common Options

  • -y: Assume "yes" to all prompts and run non-interactively.

  • -f: Attempt to correct a system with broken dependencies.

  • --purge: Remove configuration files when removing packages.

  • -d: Download only; do not install or unpack archives.

  • --no-install-recommends: Do not consider recommended packages as a dependency for installing.

For example, to install a package without recommended packages:

Conclusion

The apt-get command is a versatile and essential tool for managing software packages on Debian-based systems. By understanding its basic and advanced commands, you can effectively install, update, upgrade, and remove packages, ensuring your system stays up-to-date and free of unnecessary software.

help

Last updated