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
dpkgis the low-level tool that installs, removes, and manages.debpackages locally. It does not handle dependencies or remote repositories.apt-getis a command-line front-end todpkgthat adds support for dependency resolution and remote repositories.aptis a newer, user-friendly interface introduced to unify and simplify common functions fromapt-get,apt-cache, and others. It is suitable for most daily package management tasks.
In summary:
apt→ wraps and simplifiesapt-get+apt-cacheapt-get→ older, more stable and script-friendlydpkg→ base-level tool for handling.debfiles 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 |
5) Common commands
Search and inspect:
brew search <keyword> |
List installed files for a formula:
brew list <formula> |
Get the stable formula prefix (usually the opt path):
brew --prefix <formula> |
6) Switching versions (when versioned formulae exist)
If Homebrew provides versioned formulae (e.g., [email protected]), you can control which version is linked into $(brew --prefix)/bin:
brew unlink go |
7) Installation and mirrors (China mainland)
Homebrew installation is covered in the official documentation, so I omit it here. In mainland China, using a mirror can significantly improve reliability and download speed.
Tsinghua TUNA provides a widely used guide covering installation and mirror configuration:
- Homebrew 软件仓库(TUNA)
For an additional walkthrough (blog post):
- 如何加速 Homebrew 在 macOS 上的下载速度
Mirror configuration via environment variables (USTC example)
The following environment variables redirect different Homebrew “sources” to USTC mirrors. Add them to your shell profile (e.g., ~/.zshrc or ~/.zprofile) so they apply to every new terminal session.
# Speed up Git fetches for the Homebrew software itself (Homebrew/brew) |
Verification:
brew config |
To temoprally switch back to official source, i.e., disabling mirrors, run in current shell session:
unset HOMEBREW_BREW_GIT_REMOTE |
then:
brew update |