Pkg_Mgt                                            
*   Debian        
  9/26/22   Pkg_Mgt        
                                               
   
  Home In-depth guide to Debian package mgt.
  Install / Debian
  Pkg Mgt dpkg -l Show Installed Packages with dpkg -l
  MX dpkg --list foo For a one-line description of the installation status of package foo.
    dpkg --status foo For a more verbose description.
   
    apt-cache show msmtp get info on a package
   
    Package Management Basics: apt, yum, dnf, pkg
   
    A Brief Overview
    Operating System Format Tool(s) In Debian and systems based on it, like Ubuntu, Linux Mint, and Raspbian, the package format is the .deb file. 
    Debian .deb apt, apt-cache, apt-get, dpkg APT, the Advanced Packaging Tool, provides commands used for most common operations: Searching repositories, installing collections of packages and their dependencies, and managing upgrades.
    Ubuntu .deb apt, apt-cache, apt-get, dpkg APT commands operate as a front-end to the lower-level dpkg utility, which handles the installation of individual .deb files on the local system, and is sometimes invoked directly.
    CentOS .rpm yum The apt command, offers a concise and unified interface to common operations that have traditionally been handled by the more-specific apt-get and apt-cache. 
    Fedora .rpm dnf Its use is optional, but may simplify some tasks.
    FreeBSD Ports, .txz make, pkg
    CentOS, Fedora, and other members of the Red Hat family use RPM files.
    In recent versions of Fedora, yum has been supplanted by dnf, a modernized fork which retains most of yum’s interface.
   
    sudo apt update sudo apt-get update FreeBSD’s binary package system is administered with the pkg command. 
    sudo apt upgrade sudo apt-get upgrade FreeBSD also offers the Ports Collection, a local directory structure and tools which allow the user to fetch, compile, and install packages directly from source using Makefiles.
    It’s usually much more convenient to use pkg, but occasionally a pre-compiled package is unavailable, or you may need to change compile-time options.
   
    Update Package Lists
    System Command Most systems keep a local database of the packages available from remote repositories. 
    Debian / Ubuntu sudo apt-get update It’s best to update this database before installing or upgrading packages. 
    sudo apt update As a partial exception to this pattern, yum and dnf will check for updates before performing some operations,
    CentOS yum check-update but you can ask them at any time whether updates are available.
    Fedora dnf check-update
    FreeBSD Packages sudo pkg update
    FreeBSD Ports sudo portsnap fetch update
   
   
    Upgrade Installed Packages  
    System Command Notes Making sure that all of the installed software on a machine stays up to date would be an enormous undertaking without a package system. 
    Debian / Ubuntu sudo apt-get upgrade Only upgrades installed packages, where possible. While a package manager doesn’t solve every problem you’ll encounter when upgrading software, it does enable you to maintain most system components with a few commands.
    sudo apt-get dist-upgrade May add or remove packages to satisfy new dependencies.
    sudo apt upgrade Like apt-get upgrade.
    sudo apt full-upgrade Like apt-get dist-upgrade.
    CentOS sudo yum update
    Fedora sudo dnf upgrade
   
   
    Find a Package
    System Command Notes The quickest and most effective way to locate a package is to search with command-line tools.
    Debian / Ubuntu apt-cache search search_string
    apt search search_string
    CentOS yum search search_string
    yum search all search_string Searches all fields, including description.
    Fedora dnf search search_string
    dnf search all search_string Searches all fields, including description.
   
   
    View Info About a Specific Package
    System Command Notes When deciding what to install, it’s often helpful to read detailed descriptions of packages.
    Debian / Ubuntu apt-cache show package Shows locally-cached info about a package. Along with human-readable text, these often include metadata like version numbers and a list of the package’s dependencies.
    apt show package
    dpkg -s package Shows the current installed status of a package.
    CentOS yum info package
    yum deplist package Lists dependencies for a package.
    Fedora dnf info package
    dnf repoquery --requires package Lists dependencies for a package.
   
   
    Install a Package from Repositories Once you know the name of a package, you can usually install it and its dependencies with a single command.
    System Command Notes In general, you can supply multiple packages to install simply by listing them all.
    Debian / Ubuntu sudo apt-get install package
    sudo apt-get install package1 package2 ... Installs all listed packages.
    sudo apt-get install -y package Assumes “yes” where apt would usually prompt to continue.
    sudo apt install package Displays a colored progress bar.
    CentOS sudo yum install package
    sudo yum install package1 package2 ... Installs all listed packages.
    sudo yum install -y package Assumes “yes” where yum would usually prompt to continue.
    Fedora sudo dnf install package
    sudo dnf install package1 package2 ... Installs all listed packages.
    sudo dnf install -y package Assumes “yes” where dnf would usually prompt to continue.
   
   
    Install a Package from the Local Filesystem Sometimes, even though software isn’t officially packaged for a given operating system, a developer or vendor will offer package files for download.
    System Command Notes You can usually retrieve these with your web browser, or via curl on the command line. 
    Debian / Ubuntu sudo dpkg -i package.deb Once a package is on the target system, it can often be installed with a single command.
    sudo apt-get install -y
 gdebi && sudo gdebi package.deb
Installs and uses gdebi to install package.deb
 and retrieve any missing dependencies.
On Debian-derived systems, dpkg handles individual package files. If a package has unmet dependencies, gdebi can often be used to retrieve them from official repositories.
    CentOS sudo yum install package.rpm On CentOS and Fedora systems, yum and dnf are used to install individual files, and will also handle needed dependencies.
    Fedora sudo dnf install package.rpm
   
   
    Remove One or More Installed Packages
    System Command Notes Since a package manager knows what files are provided by a given package, 
    Debian / Ubuntu sudo apt-get remove package it can usually remove them cleanly from a system if the software is no longer needed.
    sudo apt remove package
    sudo apt-get autoremove Removes unneeded packages.
    CentOS sudo yum remove package
    Fedora sudo dnf erase package
   
   
    The apt Command
    Traditional Command apt Equivalent Administrators of Debian-family distributions are generally familiar with apt-get and apt-cache.
    apt-get update apt update Less widely known is the simplified apt interface, designed specifically for interactive use.
    apt-get dist-upgrade apt full-upgrade
    apt-cache search string apt search string
    apt-get install package apt install package While apt is often a quicker shorthand for a given operation, it’s not intended as a complete replacement for the traditional tools,
    apt-get remove package apt remove package and its interface may change between versions to improve usability.
    apt-get purge package apt purge package
    If you are using package management commands inside a script or a shell pipeline, it’s a good idea to stick with apt-get and apt-cache.
   
    Get Help
    System Command Notes
    Debian / Ubuntu man apt-get Updating the local package database and working with packages.
    man apt-cache Querying the local package database.
    man dpkg Working with individual package files and querying installed packages.
    man apt Working with a more concise, user-friendly interface to most basic operations.
    CentOS man yum
    Fedora man dnf
    In addition to web-based documentation, keep in mind that Unix manual pages (usually referred to as man pages) are available for most commands from the shell. To read a page, use man:
   
    $ man page
   
    In man, you can navigate with the arrow keys. Press / to search for text within the page, and q to quit.