Managing software on Ubuntu is made easy with the apt-get command-line tool. It is used to handle packages in Debian-based distributions. This guide covers basic everyday use commands to manage software.
Note: You can also connect the commands with &&
sudo apt update && sudo apt upgrade
| Command | Description |
|---|---|
sudo apt update |
Update the package list |
sudo apt upgrade |
Upgrade all installed packages |
sudo apt install <package_name> |
Install a new package, e.g., sudo apt install vim |
sudo apt remove <package_name> |
Remove an installed package, e.g., sudo apt remove vim |
sudo apt purge <package_name> |
Remove a package and its configuration, e.g., sudo apt purge vim |
sudo apt autoremove |
Remove unnecessary packages, e.g., sudo apt autoremove |
sudo apt clean |
Clean up the local repository of retrieved package files, e.g., sudo apt clean |
apt list --installed |
List all installed packages |
apt list --installed | grep <package_name> |
Filter installed packages, e.g., apt list --installed \| grep nvidia |
apt-cache search <package_name> |
Search for available packages, e.g., apt-cache search vim |
apt-cache show <package_name> |
Show details of a package, e.g., apt-cache show vim |
sudo apt install <package_name>=<version> |
Install a specific version of a package, e.g., sudo apt install vim=2:8.0.1453-1ubuntu1 |
Before installing or upgrading software, update the package lists from the repositories. This refreshes all apt information from the server and generally does not take long
sudo apt update
To search for available packages:
apt-cache search <package_name>
Example:
apt-cache search vim
To show details of a specific package:
apt-cache show <package_name>
Example:
apt-cache show vim
Note:
apt-get installandapt installdo the same. Except the second one is shorter.
supposedly,apt-get installhas better output for scripts (logging) whileapt installas better suited for the console (Progressbar)
sudo apt install <package_name>
Example:
sudo apt install vim
To install a specific version of a package:
sudo apt install <package_name>=<version>
Example:
sudo apt install vim=2:8.0.1453-1ubuntu1
To list all installed packages:
apt list --installed
To find a specific installed package:
apt list --installed | grep <package_name>
Example:
apt list --installed | grep nvidia
To remove a package along with its configuration files:
sudo apt-get purge <package_name>
Example:
sudo apt-get purge vim
sudo apt-get remove <package_name>
Example:
sudo apt-get remove vim
To remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed:
sudo apt-get autoremove
To clean up the local repository of retrieved package files:
sudo apt-get clean
Third-party repositories are external sources for packages not included in the default Ubuntu repositories. They can provide additional software or newer versions of existing software.
You can find third-party repositories by searching the web for the desired software and checking its official website or trusted community forums for repository information.
sudo add-apt-repository <repository>
sudo apt-get update
Replace <repository> with the repository details.
sudo add-apt-repository --remove <repository>
sudo apt-get update
Replace <repository> with the repository details.
To list all repositories, including third-party ones:
cat /etc/apt/sources.list
Or list files in the directory containing repository configurations:
ls /etc/apt/sources.list.d/