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?

1 Answer 1


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
  • 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, 2013 at 16:57
  • 3
    @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, 2013 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, 2013 at 17:00
  • @etherice - there someone else just upvoted you so now you have 16 pts.
    – slm
    Jul 31, 2013 at 17:02
  • 1
    Thanks! I ran hash -r to reset the command-to-path hashtable, and ln is back to working order now.
    – etherice
    Jul 31, 2013 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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