🔍
Artificial Intelligence Cybersecurity Windows Mac Android iPhone Software How-To Guides Reviews Comparisons Productivity Internet Apps Cloud Business Software About Contact

How to Fix "Command Not Found" Error in Linux Terminal

The "command not found" error is often the first error new Linux users encounter. It means the shell cannot find the program you are trying to run. Here is how to fix it.

Fix 1: Install the Missing Package

Many commands require you to install a package first. For example, ifconfig shows command not found because it has been replaced by ip on modern Linux. But you can still install it with sudo apt install net-tools. When you see command not found, search for the package with apt-cache search commandname. Common missing commands and their packages include: ifconfig (net-tools), telnet (telnet), wget (wget), git (git), curl (curl), make (build-essential), and python3 (python3).

Fix 2: Check Your PATH Variable

If you installed a program but it still says command not found, the program may not be in your PATH. Check your PATH with echo $PATH. If the installation directory is not in the PATH, run the program with its full path, or add the directory to PATH with export PATH=$PATH:/path/to/directory. Add this line to ~/.bashrc to make it permanent.

Fix 3: Use the Absolute Path

Some programs do not add themselves to PATH. Find the program with find /usr -name "programname" 2>/dev/null or locate programname (install mlocate first). Once you find the location, run it with the full path like /usr/local/bin/programname. For frequently used programs, create an alias in ~/.bashrc.

Fix 4: Run Local Programs with ./

If you compiled a program or downloaded a script to your current directory, you must prefix it with ./ to run it. For example, ./myprogram or ./script.sh. Linux does not search the current directory for executables by default for security reasons. This is one of the most common mistakes new Linux users make.