See below for a cheat-sheet of various Linux package manager related commands.
pacman / yaourt (Arch, Manjaro)
See this excellent Arch pacman article for more tips and tricks.
Update all installed packages using pacman
pacman -Syu
Update all installed packages using yaourt (also updates applications compiled from AUR)
yaourt -Syyua
List all installed packages by installation date
expac --timefmt='%Y-%m-%d %T' '%l\t%n'|sort -n
Remove all orphaned packages (installed packages that are no longer used/needed)
sudo pacman -Rns $(pacman -Qtdq)
Install a package with all optional dependencies
See Install a package with all optional dependencies in Arch based distros.
apt (debian/Ubuntu)
apt-get install / remove
To remove (uninstall) a package you can do:
sudo apt-get remove packageName
Note this only removes the binary and not the it's configuration files etc. To remove the binary and config files do:
sudo apt-get purge packagename
Note that this will remove binaries, config files etc. but not dependencies (which may not be needed anymore).
To remove (unneeded) dependency packages, and any other orphaned package, run:
sudo apt-get autoremove
You can do all of the above by:
sudo apt-get --purge autoremove packagename
List all installed packages by installation date
grep " install " /var/log/dpkg.log
Holding back specific packages for apt-get upgrade
You might want to stop specific packages for updating when you do an 'apt-get upgrade'. You can use 'apt-mark hold' for this. For example, to hold back upgrading gitlab-ee, you would do:
sudo apt-mark hold gitlab-ee
To un-hold and allow it to upgrade, simply do:
sudo apt-mark unhold gitlab-ee
Adding / removing ppa's
You can add a ppa repository by:
sudo add-apt-repository ppa:<ppa-name>
and remove it by:
sudo add-apt-repository --remove ppa:<ppa-name>
ppa sources are kept in
/etc/apt/sources.list.d
Adding / removing GPG keys
During the install of some software you might need to add a GPG key. For example, during the install of the awesome goaccess, you do:
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
That is we use the following to install the GPG key:
sudo apt-key add <GPG-KEY>
To remove a GPG key, let's first list all keys with
sudo apt-key list
The output will look something like this:
jay@home-server:/etc/apt/sources.list.d$ sudo apt-key list /etc/apt/trusted.gpg -------------------- pub 1024D/437D05B5 2004-09-12 uid Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com> sub 2048g/79164387 2004-09-12 pub 4096R/C0B21F32 2012-05-11 uid Ubuntu Archive Automatic Signing Key (2012) <ftpmaster@ubuntu.com> pub 4096R/EFE21092 2012-05-11 uid Ubuntu CD Image Automatic Signing Key (2012) <cdimage@ubuntu.com> pub 1024D/FBB75451 2004-12-30 uid Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com> pub 4096R/E15E78F4 2015-04-17 [expires: 2020-04-15] uid GitLab B.V. (package repository signing key) <packages@gitlab.com> pub 4096R/8183CBB5 2014-11-27 uid Odoo SA, Linux Package Signing Key <info@odoo.com> sub 4096R/ADE51428 2014-11-27 /etc/apt/trusted.gpg.d/webupd8team_ubuntu_java.gpg -------------------------------------------------- pub 1024R/EEA14886 2010-05-04 uid Launchpad VLC
To remove a key, you can use sudo apt-key del
. For example, if I wanted to remove the GitLab B.V. (package repository signing key)
key, then I would do:
sudo apt-key del E15E78F4
Viewing information about a package
apt show packageName
Make uninstall
If you install from source, in the same folder as you did
sudo make install
You can uninstall by
sudo make uninstall
So keep your source folders handy.
References
- https://askubuntu.com/questions/187888/what-is-the-correct-way-to-completely-remove-an-application
- https://www.ostechnix.com/list-installed-packages-sorted-installation-date-linux/
- https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#By_date
Related articles