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 only know of two ways: alias foo=bar and function foo() { bar }.

The reason I'm asking is that - all of a sudden in one of my bash sessions - I cannot run the ln command because bash is erroring out with -bash: /usr/local/.../ln: No such file or directory (where the /usr/local/.../ is one of the entries in my PATH environment variable).

It's not a PATH issue though, because If I run which ln it outputs the expected binary of /usr/bin/ln (which I can run fine if I specify the absolute path).

I also checked for ln in my alias and function declarations, and there is nothing:

$ declare -f | grep ln
$ alias | grep ln

The problem is just occurring in one bash session. If I start a new shell, it works fine again, but I want to know what caused this problem all of a sudden in this one particular session of bash.

Any ideas as to what could be causing this?

share|improve this question
up vote 10 down vote accepted

Be careful when using the which command. Better to use the type ... command.

$ type ln
ln is /bin/ln

You can also use the whereis command:

$ whereis ln
ln: /bin/ln /usr/share/man/man1p/ln.1p.gz /usr/share/man/man1/ln.1.gz
share|improve this answer
You're right! When I run type ln I get ln is hashed (/usr/local/.../ln) which appears to be the problem, but what does it mean exactly that it's "hashed"? I've never heard of that feature in bash. – etherice Jul 31 '13 at 16:57
@etherice - Bash maintains a hash (a key=value list) of a command's name and where it's located. You can see the list with the hash -l command. It's dynamically built as you use commands. – slm Jul 31 '13 at 16:59
@etherice - I just upvoted your question so you're only 4 pts away 8-). You can accept the answer when your issue's resolved and you feel it's the best answer. – slm Jul 31 '13 at 17:00
@etherice - there someone else just upvoted you so now you have 16 pts. – slm Jul 31 '13 at 17:02
Thanks! I ran hash -r to reset the command-to-path hashtable, and ln is back to working order now. – etherice Jul 31 '13 at 17:14

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.