======OS - Linux - Debian - Package Management======
=====Notes=====
====Get a list of installed packages====
dpkg --get-selections
Source: [[http://www.howtogeek.com/howto/linux/show-the-list-of-installed-packages-on-ubuntu-or-debian/|How-To Geek - Show the List of Installed Packages on Ubuntu or Debian]] \\
====Get the list of installed packages from specifi repo/archive====
Get the archive (a=) name of the repository to search from:
apt-cache policy
Example output:
root@storage1:~# apt-cache policy
Package files:
100 /var/lib/dpkg/status
release a=now
100 https://debian.snt.utwente.nl/debian bullseye-backports/main amd64 Packages
release o=Debian Backports,a=bullseye-backports,n=bullseye-backports,l=Debian Backports,c=main,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian bullseye-updates/main amd64 Packages
release v=11-updates,o=Debian,a=oldstable-updates,n=bullseye-updates,l=Debian,c=main,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian-security bullseye-security/non-free amd64 Packages
release v=11,o=Debian,a=oldstable-security,n=bullseye-security,l=Debian-Security,c=non-free,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian-security bullseye-security/contrib amd64 Packages
release v=11,o=Debian,a=oldstable-security,n=bullseye-security,l=Debian-Security,c=contrib,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian-security bullseye-security/main amd64 Packages
release v=11,o=Debian,a=oldstable-security,n=bullseye-security,l=Debian-Security,c=main,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian bullseye/non-free amd64 Packages
release v=11.11,o=Debian,a=oldstable,n=bullseye,l=Debian,c=non-free,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian bullseye/contrib amd64 Packages
release v=11.11,o=Debian,a=oldstable,n=bullseye,l=Debian,c=contrib,b=amd64
origin debian.snt.utwente.nl
500 https://debian.snt.utwente.nl/debian bullseye/main amd64 Packages
release v=11.11,o=Debian,a=oldstable,n=bullseye,l=Debian,c=main,b=amd64
origin debian.snt.utwente.nl
Pinned packages:
Search the installed packages for packages installed from the repository, in this example from backports/bullseye-backports:
root@storage1:~# aptitude search '?narrow(~i, ~Abackports)'
root@storage1:~# aptitude search '?narrow(~i, ~Abullseye-backports)'
Source: [[https://serverfault.com/questions/109442/how-can-i-list-all-installed-packages-from-lenny-backports|serverfault - How can I list all installed packages from lenny-backports?]]
====Set apt-get to use 1 specific mirror====
// Tested on stretch. //
To change the apt-get sources.list to only use the ftp.nluug.nl mirror:
#deb http://ftp.nl.debian.org/debian stretch main contrib
deb https://ftp.nluug.nl/debian stretch main contrib
# security updates
#deb http://security.debian.org stretch/updates main contrib
deb https://ftp.nluug.nl/debian stretch-updates main contrib
====Clean the apt cache====
Cleans out the apt cache in /var/cache/apt/archives/.
apt-get clean
Source:[[https://askubuntu.com/questions/285691/is-it-possible-to-clean-the-apt-cache-from-the-command-line|Ask Ubuntu - Is it possible to clean the APT cache from the command line?]]
=====Delete packages from previous releases=====
For deleting packages that were leftover from previous releases. In this example from debian 7 and 8 on a debian 9 system.
Test removal:
apt-get remove --dry-run `dpkg -l | egrep "deb8|deb7" | awk '{print $2 " "}' | tr -d "\n"`
Actually remove:
apt-get remove `dpkg -l | egrep "deb8|deb7" | awk '{print $2 " "}' | tr -d "\n"`
=====Force IPv4 usage======
For when apt for some reason thinks it can start using IPv6 in an environment with only IPv4 connectivity.
echo "Acquire::ForceIPv4 \"True\";" > /etc/apt/apt.conf.d/ForceIPv4