Ubuntu package management cheat sheet
- Đạt Trần
Most used commands (copy directly from the man page)
Most used commands: list - list packages based on package names search - search in package descriptions show - show package details install - install packages reinstall - reinstall packages remove - remove packages autoremove - Remove automatically all unused packages update - update list of available packages upgrade - upgrade the system by installing/upgrading packages full-upgrade - upgrade the system by removing/installing/upgrading packages edit-sources - edit the source information file satisfy - satisfy dependency strings
To remove a package
sudo apt remove package-name
To install a package
sudo apt install package-name
List installed packages
apt list --installed
Search an installed package
apt list --installed | grep package-name
To remove mulitple packages using regex wildcard:
sudo apt remove -s '*pattern*'
For example, you want to remove all
php related packages on your system, you can do like this:
sudo apt remove -s '*php*'
You’ll see messages like these:
It is because apt tries to remove all packages which match that pattern. Since, for example,
conquest-mysql not installed in my system, the remove request for that package is invalid.
However, if there are packages installed on the system, they will be removed.
For example, I tried to remove thunderbird. Since there are packages installed, they were removed:
Cleanup packages that no longer required
There are times you installed a package, some other dependencies are installed too. However, when you remove the package you installed, the dependencies may not be removed. The following command helps cleanup those redundant, left-over packages:
sudo apt autoremove