Troubleshooting

apt-get: command not found — find your system's package manager (dnf, apk, brew, winget)

apt-get exists only on Debian and Ubuntu. Check /etc/os-release and use your system's manager: dnf on Rocky and Fedora, apk on Alpine, brew on macOS, winget.

Published ~8 min read

Short answer: apt-get: command not found almost always means the system is not Debian or Ubuntu. apt-get is the package manager of the Debian family only. Rocky, AlmaLinux, Fedora and RHEL use dnf, openSUSE zypper, Arch pacman, Alpine apk, macOS Homebrew’s brew, and Windows winget. There is nothing to install: use the one that belongs to your system. Find out which that is:

Linux · macOS
cat /etc/os-release
uname -s

Read the ID= and ID_LIKE= lines and look them up below. No /etc/os-release and uname -s prints Darwin: you are on a Mac. If ID or ID_LIKE says debian or ubuntu and apt-get is still missing, the PATH or the apt package itself is broken, which is rare: fix it here.

Which message do you see?

MessageWhereCause and fix
bash: apt-get: command not found, -bash: apt-get: command not found over SSHLinux, or Git Bash on WindowsNot a Debian system: use its package manager. Fedora desktops add three dots: command not found...
zsh: command not found: apt-getmacOS TerminalHomebrew
sudo: apt-get: command not foundsudoThe same cause as above; sudo looked and found none
/bin/sh: apt-get: not foundDockerfile RUN on an Alpine imageBusyBox shell, Alpine: use apk
/bin/sh: line 1: apt-get: command not foundRUN on a Fedora, Rocky, Alma or UBI imagebash as sh, RHEL family: use dnf
exec: "apt-get": executable file not found in $PATHdocker exec CONTAINER apt-get …The container is not Debian-based: Docker
exec: "/bin/sh": stat /bin/sh: no such file or directoryRUN on distroless or scratchNo shell, no package manager: multi-stage build
'apt-get' is not recognized as an internal or external command, (cmd), The term 'apt-get' is not recognized (PowerShell)Windowswinget or WSL
E: Unable to locate package NAMEDebian, Ubuntuapt-get works; the package name or list is the problem: Unable to locate package

The bash lines are real output from Debian 12 with apt-get missing from PATH. The /bin/sh: lines come from BusyBox on Alpine and from bash running as sh on Fedora, Rocky and UBI. Fedora’s three-dot variant comes from its PackageKit command-not-found handler. apt: command not found is the same error: apt and apt-get are two front ends from one package, apt.

Which package manager does your system use?

ID or ID_LIKE containsSystemsPackage manager
debian or ubuntuDebian, Ubuntu, Linux Mint, Kali, Raspberry Pi OS, Pop!_OSapt-get
rhel or fedoraRocky, AlmaLinux, RHEL, CentOS Stream, Fedora, Amazon Linux 2023dnf (yum on CentOS 7, RHEL 7, Amazon Linux 2)
suseopenSUSE Leap, Tumbleweed, SLESzypper
archArch, Manjaropacman
alpineAlpine, most -alpine Docker imagesapk
uname -s is DarwinmacOSbrew
uname -s starts MINGW64_NTGit Bash on WindowsNone in Git Bash; winget in Windows

Ubuntu sets ID=ubuntu with ID_LIKE=debian, Rocky 9 ID="rocky" with ID_LIKE="rhel centos fedora". If uname -s prints FreeBSD, the package manager is pkg.

apt-get commands in other package managers

Taskapt-getdnfzypperpacmanapkbrewwinget
Refresh package listsapt-get updatednf makecachezypper refreshpart of pacman -Syuapk updatebrew updatewinget source update
Upgrade everythingapt-get upgradednf upgradezypper update (Tumbleweed: zypper dup)pacman -Syuapk upgradebrew upgradewinget upgrade --all
Installapt-get install PKGdnf install PKGzypper install PKGpacman -S PKGapk add PKGbrew install PKGwinget install --id ID
Removeapt-get remove PKGdnf remove PKGzypper remove PKGpacman -Rs PKGapk del PKGbrew uninstall PKGwinget uninstall --id ID
Searchapt-cache search WORDdnf search WORDzypper search WORDpacman -Ss WORDapk search WORDbrew search WORDwinget search WORD
Detailsapt-cache show PKGdnf info PKGzypper info PKGpacman -Si PKGapk info PKGbrew info PKGwinget show --id ID
List installeddpkg -ldnf list --installedzypper search -ipacman -Qapk list --installedbrew listwinget list
Which package owns FILEdpkg -S FILErpm -qf FILErpm -qf FILEpacman -Qo FILEapk info -W FILE——

In scripts, apt-get -y becomes dnf -y, zypper --non-interactive install (a global option, so it goes before the command) and pacman --noconfirm; apk never asks. On Arch, never run pacman -Sy PKG on its own: refreshing the lists without upgrading leaves a partly upgraded system, so use pacman -Syu PKG. dnf provides FILE also finds packages that are not installed yet, which is how you translate a missing command into a package name.

The package names differ too

You needDebian, UbuntuRocky, Alma, RHELAlpinemacOS
Compiler and makebuild-essential"Development Tools" groupbuild-basexcode-select --install
digbind9-dnsutilsbind-utilsbind-toolsBuilt in
ip, ssiproute2iprouteiproute2Not available
ps, top, freeprocpsprocps-ngprocps-ngBuilt in, no free
pippython3-pippython3-pippy3-pipbrew install python

On the RHEL family, install the group with sudo dnf groupinstall -y "Development Tools"; Fedora’s dnf5 calls it sudo dnf group install -y c-development.

On CentOS 7 or an old RHEL, where you get the opposite error, see yum: command not found.

macOS: use Homebrew

macOS has no apt-get and no Linux package manager of its own. Homebrew fills that role: install it with the line from brew.sh, which asks for your password and installs the Command Line Tools if they are missing.

macOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then brew install PKG replaces sudo apt-get install PKG, without sudo: Homebrew refuses to run as root. A guide that starts with apt-get install build-essential becomes xcode-select --install.

Homebrew installed but zsh cannot find it? See brew: command not found.

Windows: winget, or Ubuntu in WSL

For Windows programs, winget is the equivalent: winget install --id Git.Git -e installs Git, for example. It comes with the App Installer on Windows 10 (version 1809 or later), Windows 11 and Windows Server 2025; Server 2022 and 2019 do not include it.

If you are following a Linux tutorial, you need Linux, not a Windows package manager. Install WSL, which brings Ubuntu by default, then run the tutorial’s apt-get lines inside the Ubuntu shell:

PowerShell (as Administrator)
wsl --install

Git Bash looks like Linux but is not: it has bash and the GNU tools, and no package manager at all.

In Docker images

A Dockerfile copied from a Debian-based example fails once the base image changes: node:24-alpine, python:3.13-alpine and nginx:alpine are Alpine, while UBI and the Rocky and Fedora images belong to the RHEL family. Translate the line, or switch to the Debian-based tag, such as node:24-slim.

Dockerfile · Debian, Ubuntu base
RUN apt-get update \
 && apt-get install -y --no-install-recommends git ca-certificates \
 && rm -rf /var/lib/apt/lists/*
Dockerfile · Alpine base
RUN apk add --no-cache git ca-certificates
Dockerfile · Rocky, Alma, Fedora base
RUN dnf install -y git ca-certificates && dnf clean all

UBI minimal images ship microdnf instead of dnf, with the same install -y syntax. For docker exec, open a shell first with docker exec -it CONTAINER sh and use the image’s own manager. Whatever you install that way disappears when the container is recreated; put it in the Dockerfile.

Distroless and scratch images

These contain your program and its runtime, and no shell, so no RUN line can work in them. Install what you need in a build stage and copy only the result:

Dockerfile · multi-stage
FROM debian:13-slim AS build
RUN apt-get update \
 && apt-get install -y --no-install-recommends PACKAGES \
 && rm -rf /var/lib/apt/lists/*
# build or fetch your program here

FROM gcr.io/distroless/base-debian13
COPY --from=build /PATH/IN/BUILD/STAGE /app
ENTRYPOINT ["/app"]

Keep both stages on the same Debian release, as here, so a program built against the build stage’s libraries finds the same versions at run time. For a shell to debug with, the :debug tags of the distroless images include a BusyBox sh.

On Debian or Ubuntu, and apt-get is still missing

Rare, but it happens: a startup file that overwrote PATH, or a deleted file. Check both:

Debian · Ubuntu
ls -l /usr/bin/apt-get
echo "$PATH"

The file exists: your PATH lacks /usr/bin. Run /usr/bin/apt-get by its full path in the meantime, restore a working PATH for this session, then find the line that broke it, usually PATH=… without $PATH in it:

bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
grep -n PATH ~/.bashrc ~/.profile ~/.bash_profile /etc/environment 2>/dev/null

The file is gone: dpkg -V apt lists each missing file of the apt package on a line starting with missing. dpkg still works without apt, so reinstall the same version from Debian’s package pool:

Debian
dpkg-query -W -f='${Version} ${Architecture}\n' apt
curl -fLO http://deb.debian.org/debian/pool/main/a/apt/apt_VERSION_ARCH.deb
sudo dpkg -i apt_VERSION_ARCH.deb

Replace VERSION and ARCH with what the first line prints, for example 2.6.1 and amd64 on Debian 12. Ubuntu keeps its packages under archive.ubuntu.com/ubuntu/pool/main/a/apt/. If the server has neither curl nor wget, download the file elsewhere and copy it over with scp.

apt or apt-get?

Both come from the same package and install the same way. apt is the friendlier front end for typing, with a progress bar and colour. In scripts, use apt-get: its output stays stable between releases, and apt says so itself when its output goes into a pipe:

Example output · apt list --installed | head
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

If you would rather follow apt-get tutorials as written, pick a Debian or Ubuntu template when you order a Linux VPS: VMHeaven offers Debian 13, 12 and 11 and Ubuntu 24.04, 22.04 and 20.04, alongside CentOS Stream 9 and 8 and Rocky Linux 9 for dnf. A reinstall from the panel switches between them.

More ways to tell which distribution and release you are on: check your Linux version.

Another tool missing rather than the package manager? See command not found.

Frequently asked

Why is apt-get not found on my server?

Because the server does not run Debian or Ubuntu: apt-get exists only in the Debian family. Run cat /etc/os-release. Rocky, AlmaLinux, Fedora and RHEL use dnf, openSUSE uses zypper, Arch pacman and Alpine apk. Installing apt there is not the fix; the system's own package manager does the same job with its own package names.

How do I use apt-get on a Mac?

You don't: macOS has no apt. Install Homebrew with the command from brew.sh and use brew install PKG where a guide says sudo apt-get install PKG, without sudo. Where a guide installs build-essential, run xcode-select --install instead.

What replaces apt-get in an Alpine Docker image?

apk. Replace 'apt-get update && apt-get install -y PKG' with 'apk add --no-cache PKG' in the Dockerfile. Some names differ, for example build-base instead of build-essential and bind-tools instead of bind9-dnsutils. Or switch to a Debian-based tag such as node:24-slim and keep the apt-get line.

Related articles

All troubleshooting