Updated: 17 October 2026 · Applies to: Ubuntu 26.04 and 24.04 (tested with command-not-found 23.04, sudo-rs 0.2.13 and sudo 1.9), Debian 13, AlmaLinux 10.2, Rocky Linux 9.8, Fedora 44, openSUSE Tumbleweed, Arch Linux, Alpine 3.24
On Ubuntu, command not found means the shell found no program with that name in any folder listed in your PATH. Most of the time the package is simply not installed, and Ubuntu tells you which one to install, for example sudo apt install htop. If the program is installed, your PATH (or sudo's) does not include its folder. And if apt-get itself is not found, the system is not Debian or Ubuntu: it uses dnf, zypper, pacman or apk instead.
1. Read what Ubuntu suggests
Ubuntu's command-not-found helper looks up the missing command in the package lists. Lab example from our Ubuntu 26.04 test container (Ubuntu 24.04 printed the same):
$ htop Command 'htop' not found, but can be installed with: sudo apt install htop $ python Command 'python' not found, did you mean: command 'python3' from deb python3 command 'python' from deb python-is-python3
The same check for a user outside the sudo group:
$ ifconfig Command 'ifconfig' not found, but can be installed with: apt install net-tools Please ask your administrator.
- Install the package it names, for example
sudo apt install htop. The package name can differ from the command:ifconfigandnetstatcome fromnet-tools. - For "did you mean", use the suggested command (
python3) or install the package that adds the old name. - If you only get
foobarbaz: command not foundwith no suggestion, no Ubuntu package provides that command: check the spelling, or install the program from its vendor.
As root the suggestion has no sudo. Minimal installs and container images leave the helper out, so you get only the plain bash: htop: command not found. To add it, run sudo apt install command-not-found followed by sudo apt update.
2. Installed, but still "command not found"
First check where the shell looks:
type apt-get # apt-get is /usr/bin/apt-get echo $PATH
- Debian, normal user: Debian 13 gives normal users a
PATHwithout/usr/sbin(/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/gamesin our test), so admin tools such asuseraddreportbash: useradd: command not foundalthough/usr/sbin/useraddexists. Run them withsudo, or become root withsu -(with the dash). Plainsukept the user'sPATHin our test;su -set/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. - Every command fails, even
ls: thePATHwas overwritten, usually by a line such asexport PATH=/opt/myapp/binin~/.bashrcor~/.profile. Restore it for the current session, then fix that line so it appends instead of replacing:export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin # correct form in ~/.bashrc: export PATH="$PATH:/opt/myapp/bin"
More in how to set PATH permanently. - Works without sudo, fails with it: sudo ignores your
PATHand usessecure_pathfrom/etc/sudoers. Ubuntu 26.04 (sudo-rs) sayssudo: 'myapp': command not found; Ubuntu 24.04 (classic sudo) sayssudo: htop: command not found. Give the full path:sudo /opt/myapp/bin/myapp. - A script in the current folder:
hello.shgivescommand not found, because the current folder is not inPATH. Run./hello.sh.
3. apt-get: command not found
apt and apt-get exist only on Debian and the systems built on it (Ubuntu, Kali and others). Check which system you are on:
cat /etc/os-release
These are the messages we got for apt-get install htop on other systems (bash adds line N: when the command runs from a script):
bash: apt-get: command not found # AlmaLinux 10.2, Rocky Linux 9.8, Fedora 44, openSUSE Tumbleweed, Arch Linux sh: apt-get: not found # Alpine Linux 3.24 (common in Docker images) zsh:1: command not found: apt-get # zsh, the default shell on macOS
Use the package manager of that system instead:
- AlmaLinux, Rocky Linux, RHEL, Fedora:
sudo dnf install htop.yumstill works: it points todnf-3on AlmaLinux 10 and Rocky Linux 9, and todnf5on Fedora 44. - openSUSE and SUSE Linux Enterprise:
sudo zypper install htop - Arch Linux:
sudo pacman -S htop - Alpine Linux:
apk add htop. In a DockerfileFROM alpine, writeRUN apk add --no-cache PACKAGEinstead ofapt-get install. - macOS: there is no apt. According to Homebrew, its package manager installs software with
brew install PACKAGE. - Windows: apt works only inside WSL. According to Microsoft,
wsl --installin an administrator PowerShell installs Ubuntu by default.
Package names also differ between families: the Apache web server is apache2 on Debian and Ubuntu but httpd on AlmaLinux and Rocky Linux. Search first with apt search, dnf search or zypper search. A script written for Ubuntu needs its apt-get lines and package names changed before it runs on AlmaLinux.
4. apt-get missing on Debian or Ubuntu
- Check that the file exists:
ls -l /usr/bin/apt-get. If it does, the problem isPATH(section 2). - If it is gone, apt was removed. Download the
aptpackage for your exact release from packages.ubuntu.com or packages.debian.org and install it withsudo dpkg -i apt_*.deb. - Some container images ship without any package manager on purpose (distroless images, for example). Build from a
debianorubuntuimage if you need apt.
Related: systemctl: command not found on Mac, WSL, Docker and Alpine, add-apt-repository: command not found and netstat: command not found.
Official documentation: apt-get manual (Ubuntu) and Install WSL (Microsoft).