Package Managers for Unix-like Systems

Outline:

  • APT(Advanced Package Tool)
  • pacman

Package Managers for Unix-like Systems

APT (Advanced Package Tool)

apt is a high-level command-line interface for managing packages on Debian-based systems like Ubuntu. It simplifies tasks such as installing, upgrading, and removing software.

Relationship Between dpkg, apt, and apt-get

  • dpkg is the low-level tool that installs, removes, and manages .deb packages locally. It does not handle dependencies or remote repositories.
  • apt-get is a command-line front-end to dpkg that adds support for dependency resolution and remote repositories.
  • apt is a newer, user-friendly interface introduced to unify and simplify common functions from apt-get, apt-cache, and others. It is suitable for most daily package management tasks.

In summary:

  • apt → wraps and simplifies apt-get + apt-cache
  • apt-get → older, more stable and script-friendly
  • dpkg → base-level tool for handling .deb files directly

Commands

Here is the shortened command summary formatted as tables, grouped by task:

Update & Upgrade

Command Description
sudo apt update Refresh package index
sudo apt upgrade Upgrade installed packages
sudo apt full-upgrade Upgrade with allowed removals
sudo apt-get dist-upgrade Legacy version of full-upgrade

Install

Command Description
sudo apt install <pkg> Install a package
sudo apt-get install <pkg> Script-friendly install
sudo dpkg -i <file>.deb Install a local .deb file
sudo apt install -f Fix dependencies after dpkg install

Remove

Command Description
sudo apt remove <pkg> Remove, keep config files
sudo apt purge <pkg> Remove including config
sudo apt autoremove Remove unused dependencies

Query

Command Description
apt search <term> Search available packages in the local package index, which a locally cached list of packages and metadata downloaded from the configured repositories.
apt show <pkg> Show package details
apt list --installed List installed packages
dpkg -l List all installed packages
dpkg -L <pkg> List files from an installed package

pacman

同步存储库数据库,并且更新系统的所有软件包,但不包括不在软件库中的“本地安装的”包:

1
pacman -Syu
  • S 代表同步
  • y 代表更新本地存储库
  • u 代表系统更新

brew

brew安装的软件位置千奇百怪, 但都会在/opt/homebrew/opt留下软链接

安装:

1
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
  • 查看brew版本:

    1
    brew --version

  • 查看安装的软件版本:

    1
    brew info [name]
  • 查看某软件的可安装版本:

    1
    brew search [name]
  • brew可以对它安装的软件进行版本切换. 在最新的3.x版本使用link:

    1
    brew unlink go && brew link [email protected]

    低版本的brew使用的是switch, here is Doc


  • 查看brew安装的符号路径: 一般都位于/opt/homebrew/opt

    1
    brew  --prefix <package>
  • 查看brew安装的软件的实际路径:

    1
    brew list <package>