Linux Command Line
What is apt-get
apt-get is a command-line tool for managing software packages in Ubuntu and other Debian-based Linux distributions. It is used to install, update, upgrade, and remove software packages, as well as to manage the package repositories.
apt-get is the original package management tool for Debian-based systems, it was replaced by apt in recent version of Ubuntu. apt-get is still present in current version of Ubuntu but it’s recommended to use apt instead.
apt-get uses the same package management system (dpkg) as apt but apt-get has fewer features and a less user-friendly interface.
- Update package index: Before installing any packages, it is recommended to update the package index by running
sudo apt-get update. - Install a package: To install a package, use the command
sudo apt-get install package-name. Replacepackage-namewith the name of the package you want to install. - Upgrade a package: To upgrade a package to the latest version, use the command
sudo apt-get upgrade package-name. Replacepackage-namewith the name of the package you want to upgrade. - To reinstall a package, you can use the command
sudo apt-get --reinstall install package-name. This command will first remove the package and then install it again.Alternatively, you can use the commandsudo apt-get install package-name --reinstall.It’s important to note that the--reinstalloption will only work with packages that are already installed. If the package is not installed, the command will simply install it. - Remove a package: To remove a package, use the command
sudo apt-get remove package-name. Replacepackage-namewith the name of the package you want to remove. - Autoremove: To remove packages that were installed as dependencies and are no longer needed, use the command
sudo apt-get autoremove. - Search for a package: To search for a package, use the command
apt-cache search package-name. Replacepackage-namewith the name of the package you are searching for. - Show package information: To show information about a package, use the command
apt-cache show package-name. Replacepackage-namewith the name of the package you want to show information for. - Clean: To free up disk space by removing package files that are no longer needed, use the command
sudo apt-get clean.
See our list of 75 Linux commands you should know about.