How to Resolve Bash error: command not found

  • by

I do have an executable file in the present working directory ($PWD).

[edchen@test ~]$ ll
total 4
-rwxr--r-- 1 edchen edchen 21 Mar 12 12:45

I know I can execute it with the relative path.

[edchen@test ~]$ ./
Hello, World!

./ indicates that the execute file is in the present working directory.

Or execute it with the absolute path.

[edchen@test ~]$ /home/edchen/
Hello, World!

-bash: command not found

But I can't execute it without any indication.

[edchen@test ~]$
-bash: command not found

This time, we saw error command not found instead.


To make the shell know what we want to do, we should tell it in advance.

[edchen@test ~]$ vi .bash_profile

We add our $HOME to be one of discover-able paths of executable files.

Then we take it effect immediately.

[edchen@test ~]$ . ~/.bash_profile

We used a dot command to source all environment variables in the profile.

Then we do it again.

[edchen@test ~]$
Hello, World!

Good, this is what we want. In fact, the customized file can be executed in any directory without modifiers.

Leave a Reply

Your email address will not be published. Required fields are marked *