apt-get is a command-line utility for installing, updating, and removing packages on a Debian-based Linux system. It is a package manager for the Debian family of Linux distributions, including Ubuntu and Debian itself.
Using apt-get, you can search for and install packages from the command line, as well as upgrade and remove them. You can also update the package database and upgrade all installed packages to the latest versions.
Here are a few examples of common apt-get commands:
- apt-get update: Update the package database with the latest package information.
- apt-get upgrade: Upgrade all installed packages to the latest version.
- apt-get install package-name: Install a package.
- apt-get remove package-name: Remove a package.
- apt-get purge package-name: Remove a package and its configuration files.
- apt-get search package-name: Search for a package by name.
To use apt-get, you must have superuser privileges, which you can obtain by running the sudo command. For example, to install the nano text editor, you could use the following command:
$ sudo apt-get install nano
apt-get Command Examples
1. Update the list of available packages and versions (it’s recommended to run this before other apt-get commands):
# apt-get update
2. Install a package, or update it to the latest available version:
# apt-get install {{package}}
3. Remove a package:
# apt-get remove {{package}}
4. Remove a package and its configuration files:
# apt-get purge {{package}}
5. Upgrade all installed packages to their newest available versions:
# apt-get upgrade
6. Clean the local repository – removing package files (.deb) from interrupted downloads that can no longer be downloaded:
# apt-get autoclean
7. Remove all packages that are no longer needed:
# apt-get autoremove
8. Upgrade installed packages (like upgrade), but remove obsolete packages and install additional packages to meet new dependencies:
# apt-get dist-upgrade