apt — Debian / Ubuntu package manager — install, upgrade, remove across all 5 shells
Equivalents in every shell
sudo apt install nginxThe user-facing wrapper that replaced `apt-get` + `apt-cache` for interactive use (Ubuntu 16.04+, Debian 9+). Core verbs: `apt update` (refresh package lists from `/etc/apt/sources.list*`), `apt upgrade` (install newer versions of installed packages), `apt install <pkg>` (install — multiple packages space-separated), `apt remove <pkg>` (uninstall, keeping config), `apt purge <pkg>` (uninstall + delete config), `apt autoremove` (drop orphan deps), `apt search <q>` (search names + descriptions), `apt show <pkg>` (show metadata). Reads from `/etc/apt/sources.list` + `/etc/apt/sources.list.d/*.list`. For scripts, prefer `apt-get` over `apt` — the latter prints "CLI not stable" warnings to stderr and changes output format between releases.
sudo apt install nginxSame external. On macOS, `apt` does NOT exist — the macOS analog is `brew` (Homebrew) or `port` (MacPorts). On WSL Ubuntu / Debian, `apt` works identically to native Debian. Zsh users on Debian-family distros get `apt` via `apt-get`/`apt` completion bundled in `zsh-completions` or oh-my-zsh's `debian` plugin. Faster scripting note: `apt-cache search <q>` is the deterministic, stable, script-safe equivalent of `apt search` — same data, no "CLI not stable" warning.
sudo apt install nginxSame external. Fish completion for `apt` ships with the fish core (`__fish_apt_no_subcommand` etc) — tab-complete subcommands + installed package names. Fish-specific tip for unattended installs: `set -x DEBIAN_FRONTEND noninteractive; sudo -E apt install -y <pkg>` — same `DEBIAN_FRONTEND` pattern as bash but using fish's `set -x` env-var syntax. Note that `sudo -E` preserves the env; without it, `DEBIAN_FRONTEND` is stripped.
winget install nginxNo native PowerShell `apt` — Windows uses `winget` (Windows Package Manager, official, since Windows 10 21H1 / Windows 11) or `choco` (Chocolatey, community) or `Install-PackageProvider`/`Install-Module` (PSGallery for PowerShell modules specifically). `winget install <id>` is the closest 1:1 to `apt install <pkg>`; `winget upgrade --all` ≈ `apt upgrade`; `winget search <q>` ≈ `apt search`. `winget` package IDs are usually `Vendor.Product` form (`Microsoft.PowerShell`, `Git.Git`) — search to find the exact ID. To run `apt` from pwsh on Debian-family Linux, just call it: `& sudo apt install nginx` (same as in bash — pwsh on Linux shells out to system tools transparently).
winget install nginxNo cmd-native package manager either. `winget` is preferred (official, on every recent Win10/11). `choco install <pkg>` (Chocolatey) is the older community alternative — broader catalog, but requires a separate install (`Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))` from elevated pwsh once). `scoop` is a third option (user-scope, no admin needed). Inside WSL Ubuntu: `wsl sudo apt install <pkg>` works from cmd — `wsl` bridges to the Linux command line.
Worked examples
Update package index and install a package
sudo apt update && sudo apt install -y nginxsudo apt update; and sudo apt install -y nginxwinget install nginxwinget install nginxSearch for available packages matching a query
apt search nginxapt search nginxwinget search nginxwinget search nginxList installed packages, then remove one
apt list --installed | grep nginx && sudo apt purge -y nginxwinget list --name nginx; winget uninstall nginxwinget list --name nginx & winget uninstall nginxGotchas
- `apt update` updates the LIST of available packages; `apt upgrade` actually upgrades INSTALLED packages. New users routinely run only one and wonder why their system didn't get patched, or why "no installation candidate" errors appear after install — the canonical pair is `apt update && apt upgrade`. `apt update` alone never installs anything.
- Scripts should use `apt-get` (or `apt-get`-equivalent verbs on `apt`), NOT plain `apt`. The `apt` wrapper prints `WARNING: apt does not have a stable CLI interface. Use with caution in scripts.` to stderr on every script invocation. Beyond the noise, `apt`'s output format and exit codes are not contracted — between releases they may change. `apt-get install -y --no-install-recommends <pkg>` is the standard scripted form (the `-y` auto-confirms, `--no-install-recommends` skips the "recommended" deps that bloat container images).
- The `--no-install-recommends` flag is the difference between a 50MB and a 500MB Docker layer. APT by default installs "Recommends" alongside "Depends" — packages tagged as nice-to-have. On servers / containers this typically pulls in `man-db`, fonts, docs, and indirect GUI deps you don't want. The Debian-recommended Dockerfile pattern is `RUN apt-get update && apt-get install -y --no-install-recommends <pkg> && rm -rf /var/lib/apt/lists/*` — the trailing `rm` shrinks the layer by removing the package list cache.
- macOS does not have apt and never will — every Stack Overflow answer telling you to `apt install` on macOS is wrong. The macOS package manager is Homebrew (`brew install`); MacPorts (`port install`) is the older alternative. On a Mac, `apt` is sometimes available via WSL-equivalent VMs (Multipass, Lima, Docker), but it doesn't manage the host OS.
- PPA / third-party repos add to `/etc/apt/sources.list.d/*.list` and import their signing key into `/etc/apt/trusted.gpg.d/`. Modern Ubuntu (22.04+) DEPRECATES `apt-key add` — keys must be stored as `.gpg` files under `/etc/apt/trusted.gpg.d/` with `signed-by=` in the `.list` file pointing to them. Old tutorials with `curl ... | sudo apt-key add -` produce a warning today and will stop working on future releases — use `sudo gpg --dearmor -o /etc/apt/keyrings/<vendor>.gpg` and reference via `deb [signed-by=/etc/apt/keyrings/<vendor>.gpg] ...` in the sources.list line.