If you are a newcomer to Linux, the terminal can be intimidating. That intimidation quickly turns to frustration when you type a tutorial command exactly as written, only to be met with the dreaded bash: command not found error.
This error simply means that Ubuntu does not know what you want it to do. Fortunately, it is almost always caused by one of three very fixable issues. Here is how to fix the “Command Not Found” error in the Ubuntu terminal.
1. Check for Typos (The Most Common Culprit)
The Linux terminal is incredibly unforgiving. Unlike a Google search, it will not attempt to guess what you meant if you spell something wrong. Furthermore, the Linux terminal is case-sensitive.
If a tutorial tells you to type python3, typing Python3 (with a capital P) will result in a “Command Not Found” error. Double-check your spelling, ensure your spacing is correct, and verify that you are using the exact capitalization required.
2. Install the Missing Software Package
Often, tutorials assume you already have certain fundamental developer tools installed on your system. If you try to use a tool like curl or git and get an error, it is likely because that software simply isn’t installed on your hard drive yet.
To fix this, you need to ask Ubuntu’s package manager to download it for you. Type the following command (replacing “git” with the actual command you are trying to use):
sudo apt update
sudo apt install git
Ubuntu will ask for your administrator password, download the software, and install it. Once the installation is finished, try running your original command again.
3. Fix Your System $PATH Variable
If you know you installed the software (perhaps you downloaded a custom script from GitHub), but Ubuntu still says “Command Not Found,” you likely have a PATH issue.
The $PATH is a hidden list of specific folders. When you type a command, Ubuntu only searches inside those specific folders to find the program. If you installed a custom program in your Downloads folder, Ubuntu has no idea it exists because it is not looking there.
You can check where Ubuntu is currently looking by typing:
echo $PATH
To fix this, you have two options:
- The Easy Way (Absolute Paths): Instead of just typing the command, tell Ubuntu exactly where the file is. For example, instead of typing
myscript.sh, type the full path:/home/username/Downloads/myscript.sh - The Advanced Way (Adding to PATH): You can permanently add the new folder to your system’s search list. Open your bash configuration file by typing
nano ~/.bashrc. Scroll to the very bottom and add this line:export PATH="$PATH:/path/to/your/custom/folder". Save the file (Ctrl+O, Enter, Ctrl+X), and then refresh your terminal by typingsource ~/.bashrc.
Once your PATH is corrected, Ubuntu will finally be able to locate and execute your commands.