Packages can be updates using graphical user interface (GUI) and command line interface (CLI) in Linux. This post discusses about various commands which can be used for managing the software installed on the device running Linux.
apt-get is the command-line tool for handling packages.
- Install package
sudo apt-get install <package name>
install is followed by one or more packages desired for installation or upgrading. All packages required by the package(s) specified for installation will also be retrieved and installed. A specific version of a package can be selected for installation by following the package name with an equals and the version of the package to select.
For example, below command is used for installing git
sudo apt-get install git
- Install existing package
sudo apt-get reinstall <package name>
It is an alias for install –reinstall.
- Fix broken package by re-installing
sudo apt install -f --reinstall <package name>
-f (--fix-broken)option attempt to correct a system with broken dependencies in place.
--reinstalloption re-install packages that are already installed and at the newest version. Following example resolve the broken dependencies by reinstalling minimal python3.
sudo apt install -f --reinstall python3-minimal
apt is a command-line utility for installing, updating and removing packages on Debian.
- Fetches the list of available updates
sudo apt update
It is used to download package information from all configured sources.
- Installs updates; does not remove packages
sudo apt upgrade
It is used to install available upgrades of all packages currently installed on the system from the sources configured. New packages will be installed if required to satisfy dependencies, but existing packages will never be removed.
- Installs updates; may also remove some packages, if needed
sudo apt full-upgrade
- Removes any old packages that are no longer needed
sudo apt autoremove
It is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies changed or the package(s) needing them were removed in the meantime.
- Remove installed package
sudo apt-get remove <package name>
remove is identical to install except that packages are removed instead of installed. Removing a package leaves its configuration files on the system.
- Remove installed package along with configuration
sudo apt-get purge <package name>
purge is identical to remove except that packages are removed and purged (any configuration files are deleted too).