Package management
Commands
add-apt-repository
- 
APT repositories (/etc/apt/sources.list) are made of three parts, delimited by whitespace: - Source type: debfor binary packages ordeb-srcfor source packages
- Base URL of the source: beginning with http://,ftp://,file://, or evencdrom:
- Name of the chosen distribution followed by sections that differentiate packages by license. Kali contains main,non-free, andcontrib.
 deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ bionic main restricted deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ bionic universe deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ bionic-updates main restricted deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ bionic-updates universeadd-apt-repository "deb http://security.ubuntu.com/ubuntu trusty-security main universe" # Ubuntu add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" # Docker add-apt-repository "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" # gcloud add-apt-repository "deb http://security.ubuntu.com/ubuntu trusty-security main universe" # mailx add-apt-repository "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" # MongoDB add-apt-repository -y "ppa:kgilmer/regolith-stable" # Regolith Linux
- Source type: 
apt-key
- 
apt-key is typically used by piping a GPG key from curl. # Google Cloud SDK curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - # Docker in WSL curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -Add key specified by apt in error message apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68980A0EA10B4DE8Install key from Mono apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
apt
dnf
- 
View history of dnf commands dnf history dnf history userinstalled # View all packages installed by userPackage groups can be specified using the group command or by prefixing the package group name with @dnf info @virtualization # dnf group info virtualization dnf install @virtualization # dnf group install virtualization dnf install --with-optional @virtualization # Include optional packagesRemove the configuration backend supporting the use of legacy ifcfg files in NetworkManager. dnf remove NetworkManager-initscripts-ifcfg-rhModules are special package groups representing an application, runtime, or a set of tools. The Node.js module allows you to select several streams corresponding to major versions. dnf module install nodejs:12Global dnf configuration is stored in either /etc/yum.conf or /etc/dnf.conf. [main] ; Exclude packages from updates permanently exclude=kernel* php* ; Suppress confirmation assumeyes=TrueThe configuration can be dumped from the command-line (as root) dnf config-manager --dump
Repos
- 
Repositories are INI files placed in /etc/yum.repos.d/, but they can also be displayed and manipulated from the command-line. Repositories# Display repos dnf repolist # -v # Display enabled repos dnf repolist --enabled # Display a single repo dnf repoinfo docker-ce-stable # Add repo dnf config-manager --add-repo $REPO-URL # Disable repo dnf config-manager --set-disabled $REPO-NAMEExample repos[docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://download.docker.com/linux/fedora/$releasever/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://download.docker.com/linux/fedora/gp [kubernetes] name=Kubernetes baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg [google-cloud-sdk] name=Google Cloud SDK baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=0 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpgModules are collections of packages that are installed together. They often also have profiles available, which are variants of the module: i.e. client, server, common, devel, etc. dnf module list php dnf module install php:7.4/devel dnf module reset php
flatpak
- 
Flatpak is one of several recent containerized application distribution solutions for Linux. Flatpak runtimes are compiled reproducibly using BuildStream and they are installed in /var/lib/flatpak/runtime. Like Steam, flatpak uses BubbleWrap to implement sandboxing. Flathub is the de facto Flatpak repo, but it must be added to flatpak installations manually. flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo # Confirming success flatpak remotesDisplay installed flatpak applications, including runtime flatpak list --app --runtimeOutput columns can also be specified individually after --column(comma-delimited)flatpak list --app --columns=name,application,runtimeFlatpak applications sometimes do not adopt the system theme. The workaround involves first granting some or all applications access to the themes folder. flatpak override --filesystem=$HOME/.themesThen apply the theme by setting the GTK_THEMEenvironment variable. The value of this variable must be the folder name of a theme installed to the themes folder (typically ~/.themes).flatpak override --env=GTK_THEME=my-themeThe value of the current theme can be retrieved using gsettings gsettings get org.gnome.desktop.interface gtk-theme
pacman
- 
pacman -Q # --queryDisplay all orphaned dependencies (no longer needed) pacman -Qdt # --query --deps --unrequiredDisplay only explicitly installed packages and versions pacman -Qe # --query --explicitDisplay explicitly installed packages, limiting output to program names pacman -Qeq # pacman --query --explicit --quietDisplay all packages installed from the AUR pacman -Qm # --query --foreignDisplay all packages installed from main repos pacman -Qn # --query --nativeFind which package owns {file} pacman -Qo file # --query --ownsList all install packages, filtering output to packages that are out-of-date on the local system pacman -Qu # --query --upgradesRemove $PACKAGEpacman -R $PACKAGE # --remove packageRemove $PACKAGE, dependencies, and config filespacman -Rns $PACKAGE # --remove --recursive --nosaveRemove $PACKAGEas well as its dependenciespacman -Rs # --remove --recursiveInstall $PACKAGEfrom the AURpacman -S $PACKAGE # --syncRemove all packages from the cache as well as unused sync databases pacman -Scc # --sync --clean --cleanDisplay information about {package} pacman -Si $PACKAGE # --sync --info packageSearch for $PACKAGEin AUR repospacman -Ss $PACKAGE # --sync --search packageSearch for packages matching $PATTERNpacman -Ss $PATTERN # --sync --search patternUpdate package database pacman -Sy # --sync --refreshUpdate all packages from AUR and official repos pacman -Syu # --sync --refresh --sysupgradeForce refresh of all package databases, even if they appear to be up-to-date pacman -Syy # --sync --refresh --refreshDownload program updates but don't install them pacman -Syyuw # --sync --refresh --refresh --sysupgrade --downloadonlyGet number of total installed packages pacman -Q | wc -l
rpm
- 
Query repos for information on a package rpm -qi $PACKAGE # --query --infoUpgrade or install a package, with progress bars rpm -Uvh $PACKAGE # --upgrade --verbose --hashDisplay version of Fedora rpm -E %fedoraImport a keyring rpm --import "https://build.opensuse.org/projects/home:manuelschneid3r/public_key"
snap
- 
Snap is one of several recent containerized application distribution solutions for Linux. Snap apps are slow to start because data is stored in squashfs images. dnf install -y snapd ln -s /var/lib/snapd/snap /snap