Linux Commands

What Does Exit Code 127 Mean in Linux

In Linux and Unix-based systems, the exit code 127 refers to an invalid command to run in a bash script.

The exact meaning of the standard error message 127 is “Command Not Found”. This is a way of communication of the system indicating that the particular command given by the user is not executable as the system couldn’t find it in any of the defined PATH environment variables.

When we run the command in the terminal, it matches the given command with the paths in $PATH variables. In this case, there are two possibilities: either the system returns the successful value, or shows some error message if it can’t get the required result. Sometimes, it happens because of a misconfigured system or you might have entered the wrong command.

Possible Solutions to Overcome Error Code 127

To overcome this error, there could be the following possibilities:

  1. First, ensure you have entered the correct command (there’s no spelling mistake).
  2. You must confirm that the executable command exists under the $PATH environment variables tree.
  3. Another possibility is to write the PATH variable along with the parent directory like /bin/whoami instead of whoami.

To enlist the Linux system $PATH variables, run the mentioned-below command in the bash shell:

echo $PATH


Ensure that your path to the executable command lies in the variable environments mentioned above.

If the error is still found and the path to your command seems invalid or doesn’t exist, then we can also add the path to the $PATH environment variables using the export command.

Use the following syntax to add the required path in the $PATH environment variable:

export PATH=“<path_name>:$PATH

For example, to add the /bin/xyz path in the $PATH variable, the command would be:

export PATH=“/bin/xyz:$PATH



Sometimes when working with Linux systems, we may encounter an error message that says “command not found”. This error message is a standard exit code 127 and it means that the system cannot find the command that we have entered. There are several reasons why this error may occur, one of which is that the command path doesn’t exist in the PATH environment variable. In this guide, we will explain what the 127 error means and provide possible solutions to fix it.

About the author

Syeda Wardah Batool

I am a Software Engineer Graduate and Self Motivated Linux writer. I also love to read latest Linux books. Moreover, in my free time, i love to read books on Personal development.