[Solved] Bash: Command Not Found Error in Linux

Fix Bash Command Not Found In Linux

When you type a command in the Linux Terminal, you expect an output. But sometimes you might encounter ‘Bash : Command Not Found’ error in the terminal. In this article, we will take a look at why this error occurs and how can we resolve this issue.

Fixing the Command Not Found Error in Linux

This error simply means that the command you entered is not recognized by the shell (bash) because either that command is not installed or you are typing the command that does not exist. This could also be due to misspelled command. Let’s check how we can fix this error.

Method 1. Check The Spelling

You might have made a spelling mistake while typing the commands. Even I sometimes become confused between I (Capital i) and l (Small L) and 1 (numeric 1). Make sure that you have entered the correct command name and that you have used the spaces and options in the command correctly. For example, here I have typed the wrong command, and therefore I have encountered the error.

Type The Correct Command
Type The Correct Command

Method 2. When the Command is not installed

Maybe the command you are trying to use is not installed on your distribution. In that case, install the command using your appropriate package managers such as apt, Pacman, DNF, or zypper. For example, I don’t have nano installed on my system because I use the Vim text editor. But if I try to open my .bashrc file using nano, I will receive the mentioned error.

Make Sure That Package Is Installed
Make Sure That Package Is Installed

Method 3. When the command in use is an Alias

We often store our commands in the bashrc file in the form of an alias so that we do not have to type long commands often. But this can create problems for you, especially when you log in to the same computer using another user ID or when you access any other computer. In that case, try to find out the correct command for what you’re trying to achieve. You can also go back to your PC/User and type the following command to know all the aliases stored for you in the bashrc file:

alias
Check Aliases For Your User
Check Aliases For Your User

Now you can copy-paste the actual commands in the Terminal.

Summary

There certainly isn’t one way to fix this problem, as there could be a number of reasons causing this problem in the first place. Hopefully, the above-mentioned methods were able to fix this error for you.