When you install a Linux system, probably one of the first tasks you do is installing a program. If you are using a system you don’t know, here you can find what is the default package manager in your Linux system and how to use it.

When using the following commands, you may need to use “sudo” or be a root user.

Table of Contents

apt (Debian/Ubuntu)

  • Update repositories
    apt update
    
  • Upgrade installed packages
    apt upgrade
    
  • Search a package in repositories
    apt search <search term>
    
  • Install a package
    apt install <package name>
    
  • Uninstall a package
    apt remove <package name>
    
  • Remove unneeded dependencies
    apt autoremove
    

pacman (Arch Linux, Manjaro, EndevourOS)

  • Update repositories
    pacman -Sy
    
  • Upgrade installed packages
    pacman -Su
    
  • Update repos and then upgrade installed packages
    pacman -Syu
    
  • Search a package in repositories
    pacman -Ss <search term>
    
  • Install a package
    pacman -S <package name>
    
  • Uninstall a package
    pacman -R <package name>
    # add --nosave to remove config files
    
  • Install a pakage file
    pacman -U package.pkg.tar.xz
    
  • List unneeded dependencies
    pacman -Qdt
    

apk (Alpine Linux)

  • Update repositories
    apk update
    
  • Upgrade installed packages
    apk upgrade
    
  • Search a package in repositories
    apk search <search term>
    
  • Install a package
    apk add <package name>
    
  • Uninstall a package
    apk del <package name>
    

dnf (Fedora/CentOS/Oracle Linux)

  • Update repositories
    dnf check-update
    
  • Upgrade installed packages (also updates repositories)
    dnf upgrade
    
  • Search a package in repositories
    dnf search <search term>
    
  • Install a package
    dnf install <package name>
    
  • Uninstall a package
    dnf remove <package name>
    

yum (Amazon Linux/Fedora/CentOS/Oracle Linux)

  • Update repositories
    yum check-update
    
  • Upgrade installed packages (also updates repositories)
    yum upgrade
    
  • Search a package in repositories
    yum search <search term>
    
  • Install a package
    yum install <package name>
    
  • Uninstall a package
    yum erase <package name>
    

zypper (OpenSUSE)

  • Update repositories
    zypper refresh
    
  • Upgrade installed packages
    zypper update
    
  • Search a package in repositories
    zypper search <search term>
    
  • Install a package
    zypper install <package name>
    
  • Uninstall a package
    zypper remove <package name>
    

pkg (FreeBSD)

  • Update repositories
    pkg update
    
  • Upgrade installed packages
    pkg upgrade
    
  • Search a package in repositories
    pkg search <search term>
    
  • Install a package
    pkg install <package name>
    
  • Uninstall a package
    pkg remove <package name>
    

emerge (Gentoo)

  • Update repository
    emerge --sync
    
  • Upgrade installed packages
    emerge --update @world
    # add --ask to ask confirmation before upgrade
    # add --deep to include dependencies
    
  • Search a package in repository
    emerge --search <search term>
    # add --searchdesc to search through the descriptions
    
  • Install a package
    emerge <package name>
    
  • Uninstall a package
    emerge --deselect <package name>