This article explains how to use the apt-get and apt-cache commands in the Ubuntu environment for installing, uninstalling, and finding software packages. These commands are applicable for systems running Ubuntu or Debian.
Retrieve update list:
sudo apt-get update
Install a software package:
sudo apt-get install package name -y
Search for a software package:
sudo apt-cache search package name
Display information about a software package:
sudo apt-cache show package-name
Uninstall a software package (retain configuration files):
sudo apt-get remove package-name
Remove a software package (do not retain configuration files):
sudo apt-get purge package-name
Remove unneeded dependencies:
sudo apt-get autoremove
PPAs (Personal Package Archives) are provided by the Ubuntu community for installing the latest software, but they come with certain risks. For instance, a new version of PHP might be released that is not included in the current Ubuntu distribution. If someone in the community has developed a package for this new version, it can be installed via a PPA. Below are the commands for installation and uninstallation, where 'ppa:author/ppa-name' needs to be replaced with the respective package name.
# add a PPA
sudo add-apt-repository ppa:author/ppa-name
# remove a PPA
sudo add-apt-repository --remove ppa:author/ppa-name
Aliases are shortcuts in the Linux command line designed to simplify input. The system file where aliases are stored is ~/.bash_profile. The following aliases can be added to this file.
alias apti="sudo apt-get install"
alias aptr="sudo apt-get remove"
alias aptar="sudo apt-get autoremove"
alias aptp="sudo apt-get purge"
alias apts="sudo apt-cache search"
alias aptinfo="sudo apt-cache show"
alias addppa="sudo add-apt-repository"
alias removeppa="sudo add-apt-repository --remove"
Once the aliases are set, if we want to install nginx, we can use the shortcut command below for installation.
apti nginx
23-02-2024 02:02:07
22-02-2024 03:19:32
22-02-2024 03:16:03
22-02-2024 03:14:03
22-02-2024 03:11:58