Ad Space — Top Banner

bash: command not found

Linux Linux

Severity: Minor

What Does This Error Mean?

The 'bash: command not found' error means the shell looked through all the standard program locations and could not find what you typed. This usually means the program is not installed, is installed in a non-standard location, or the command name was mistyped. For everyday Linux use, the fix is simply to install the missing package or correct the typo.

Affected Models

  • Ubuntu
  • Debian
  • Fedora
  • CentOS
  • Arch Linux
  • Linux Mint
  • openSUSE

Common Causes

  • The program is not installed on the system
  • The program is installed in a directory not listed in the PATH environment variable
  • The command name was typed incorrectly — Linux commands are case-sensitive
  • The script being run has a typo or references a program that was removed
  • You are logged in as a different user whose PATH does not include the directory where the command lives

How to Fix It

  1. Check for a typo first. Retype the command carefully. Remember that Linux is case-sensitive — 'WGET' and 'wget' are treated as different commands. Press the Up arrow key to recall previous commands and check for mistakes.

    The most common cause of this error is simply a typo. Always check spelling first before assuming the program is not installed.

  2. Search for the package name to install it. On Ubuntu/Debian: sudo apt search [command-name] — on Fedora/RHEL: sudo dnf search [command-name] — on Arch: sudo pacman -Ss [command-name]

    The package name is not always the same as the command name. Searching shows available packages related to the command you need.

  3. Install the missing program. On Ubuntu/Debian: sudo apt install [package-name] — on Fedora: sudo dnf install [package-name] — on Arch: sudo pacman -S [package-name]

    After installing, retry the command. You should not need to restart the terminal.

  4. Check if the command exists in a non-standard location. Type: which [command-name] or type [command-name] — if it returns a path, the command exists but is not in your PATH.

    If the command is found by 'which' but still gives 'command not found,' the directory is not in your PATH. Add it with: export PATH=$PATH:/path/to/directory

  5. On Ubuntu, use the command-not-found helper. If you see a suggestion like 'Command xyz not found, but can be installed with: sudo apt install xyz' — simply run that suggested command.

    Ubuntu and Linux Mint include a handler that suggests the correct package to install for common missing commands. Follow its suggestions.

When to Call a Professional

This error never requires professional help — it is a standard Linux user issue. If you are working in a corporate or managed environment and are not allowed to install software, contact your system administrator.

Frequently Asked Questions

Why does Linux say 'command not found' when the file clearly exists?

Linux only runs programs that are in directories listed in your PATH variable. PATH is like a list of folders Linux checks whenever you type a command. If a program lives in a folder not on that list — for example, a script in your current directory — Linux will not find it. Run the command with its full path like ./scriptname or /home/user/scripts/scriptname to run it directly.

What is the difference between apt and apt-get?

Both install software on Debian-based systems like Ubuntu. apt is the newer, friendlier version of apt-get and is recommended for interactive use. apt-get is the older version preferred in scripts because its output format is stable and predictable. For everyday use, apt is fine. Both will work for installing packages.

I installed the program but still get command not found. What do I do?

After installation, if the command still is not found, the package may have installed the program under a different name. Try: dpkg -L [package-name] | grep bin (on Debian/Ubuntu) to list all files the package installed in executable directories. Alternatively, close and reopen the terminal window — some shell configurations only pick up new commands in a fresh session.