Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a program on my path. The program runs when executed with a full path specified. But the program cannot be found when I run it with just its name.

Essentially, I want to understand how the below output is possible, and how to fix it so that my program can actually be found without a full path specified:

root:/usr/local/bin# ./siege
siege: could not open /usr/local/bin/etc/siegerc
run 'siege.config' to generate a new .siegerc file
root:/usr/local/bin# echo $PATH
root:/usr/local/bin# siege
bash: /usr/bin/siege: No such file or directory
root:/usr/local/bin# wtf!?!?

I'm on Ubuntu 12.04 using bash. Also please note the warning output from siege is not relevant for the purposes of this question, as I am only interested in whether or not the program can be found and invoked.

share|improve this question
up vote 26 down vote accepted

Note the output here:

root:/usr/local/bin# siege
bash: /usr/bin/siege: No such file or directory

Bash maintains an internal hash of previously found executables in your path. In this case, it has details that at one time there was an executable at /usr/bin/siege, and reuses that path to avoid having to search again. You need to tell bash to manually rehash the path for siege like so:

hash siege

You can also clear all hashed locations:

hash -r
share|improve this answer

Chris solved your immediate problem, but you also asked to understand the results you saw. Beginning with the first line...

root:/usr/local/bin# ./siege

The (./) prefix means to look for the file 'siege' only in the current directory. The PATH is not consulted at all. Thus, /usr/local/bin/siege must exist and apparently it does or else you'd get a "No such file or directory" error.

siege: could not open /usr/local/bin/etc/siegerc

This line tells us that the /usr/local/bin/siege script is probably attempting to open 'etc/siegerc' instead of '/etc/siegerc'. Without the leading (/), bash looks for 'etc/siegerc' in the current directory. Thus, /usr/local/bin/etc/siegerc. Again, the PATH is not being consulted at all. PATH is only searched for command names. For anything else, the script must use the full path. A simple illustration...

 root@LX03:~  ls -l df
ls: cannot access df: No such file or directory
 root@LX03:~  ls -l /bin/df
-rwxr-xr-x 1 root root 67316 2011-08-17 11:04 /bin/df
share|improve this answer

Another cause of this problem might be that the path to the executable itself is on the path, instead of the executable's containing directory.

So instead of putting


on the path, merely add this

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.