We will see what are package managers in OS(linux, mac) like (apt, brew, pacman) etc, and what’s the role of those.

A simple definition would be, Package Managers are used to Download, Install, Uninstall(remove) softwares from our Operating System.

Linux#

Compare to windows and mac, linux has numerous distros(fork from linux and rewamp on top of linux kernel), those distros are grouped into families.

  • Debian Family - Ubuntu, Pop_OS(My :>), Mint etc.
  • Redhat Family - Fedora, Cent OS etc.
  • Arch Family - Arch, Omarchy(DHH one) etc.
  • Others - Alpine linux, nix etc.

Debian Family#

Debian family uses a package manager called apt stands for Advanced Packaged Tool, this tool is used to install, remove, delete any softwares in your OS. dpkg is another command that installs .deb(binary files) files directly.

Some commands


apt update # Refreshes/updates package metadata
apt install nginx # Install's nginx software
apt remove nginx # Remove/Uninstall nginx software
apt autoremove # Remove unused dependencies(that have been downloaded with these softwares)
dpkg -i nginx.deb # install's direct .deb files

Package metadata/repos will be listed mostly under /etc/apt/sources.list

Red Hat Family#

Red Hat family uses a package manager called yum stands for Yellowdog Updater, Modifier. this tool is used to install, remove, delete any softwares in your OS. rpm is another command that installs .rpm(binary files) files directly.

Some commands


yum update # Refreshes/updates package metadata
yum install nginx # Install's nginx software
yum remove nginx # Remove/Uninstall nginx software
rpm -ivh nginx.rpm # install's direct .deb files

Package metadata/repos will be listed mostly under /etc/yum.repos.d

NOTE: Modern Redhat distros uses something called dnf Dandified YUM.

Arch Family#

Red Hat family uses a package manager called pacman, this tool is used to install, remove, delete any softwares in your OS.

Some commands


pacman -Syu # Syncs and refreshes/updates package metadata
pacman -S nginx # Install's nginx software
pacman -R nginx # Remove/Uninstall nginx software

NOTE: Alpine Linux distros uses something called apk

Mac#

Mac uses a package manager called brew homebrew, this tool is used to install, remove, delete any softwares in your OS. Mac also has .dmg kinda installation, where u download .dmg(disc image) files upon clicking that it will mount to a temporary location and then installs that software into your Applications folder.

Some commands


brew update # Refreshes/updates package metadata
brew install nginx # Install's nginx software
brew uninstall nginx # Remove/Uninstall nginx software
brew upgrade

Package metadata/repos will be listed mostly under /etc/apt/sources.list

All these package managers, will store their repositories(OSS packages) on their centrailised servers. for EG: ubuntu. brew alone is different, it clones the homebrew-core git repo and then download the specific formulae(kinda hash) for that specific software.

There is also another method, you may have seen, some softwares has .gz | .xz file extensions, these are not specific to any particular OS|distros, these can be installed across OS’s, these are basically compressed binary file or full source code. .gz refers to gzip compression, .xz refers to xz compression. There are two types in here, full source code compression, binary file compression. for EG:

# nginx-1.26.1.tar.gz -> this is a full source code compression, you can download 
# this from nginx, after downloading
tar -xf nginx-1.26.1.tar.gz # this will uncompress and create a folder called nginx-1.26.1
cd nginx-1.26.1 ## cd and then install neccessary steps based on the README

# node-12.26.1.tar.xz -> this is a binary code compression, you can download 
# this from node, after downloading
tar -xf node-12.26.1.tar.gz # this will uncompress and you will get a binary file.
# Now you just need to link this binary file into your OS env bin execution
# for EG: 
sudo mv node-12.26.1 /usr/local/node
sudo ln -s /usr/local/node/bin/node /usr/local/bin/node