Useful Things
APT
APT is the package manager for Debian and the likes. I use it on Ubuntu, so here’s some useful commands I occasionally need.
Update and Upgrade
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
more convenient as an alias in .bashrc
including snaps:
alias up='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y && sudo snap refresh'
Mark packgage as automatically installed
apt-mark auto <package>
This allows the package to be cleaned up by apt autoremove
, don’t use it on critical packages like ubuntu-desktop
.
See the manpages for more options.
Show all manually installed packages
apt-mark showmanual
For moving to a new system or purging single-use programs. via Ask Ubuntu
Reverse dependencies
apt-cache rdepends <package>
Do you really need that library anymore? This command shows you which packages depend on it, so you can decide whether to keep it. via Ask Ubuntu
PostgreSQL
Shell
sudo -u postgres psql
Check Version
Server version:
pg_config --version
Client version:
psql --version
via Stack Overflow
Upgrade PostgreSQL
OLD=16
NEW=$((OLD+1))
sudo apt install -y postgresql-$NEW
sudo systemctl stop postgresql$OLD
sudo pg_upgradecluster $OLD main
If the new cluster works:
sudo pg_dropcluster $OLD main