I look to see where the command is located:

xxx:~/mono/mono-2.6.7$ which mono

If I execute it directly, no problem:

xxx:~/mono/mono-2.6.7$ /usr/local/bin/mono -V
Mono JIT compiler version 2.6.7 (tarball Mon Aug  2 16:01:50 UTC 2010)
Copyright (C) 2002-2010 Novell, Inc and Contributors. www.mono-project.com

But if I execute the command without the path it cannot find it:

xxx:~/mono/mono-2.6.7$ mono
bash: /usr/bin/mono: No such file or directory

There is no mono file in /usr/bin:

xxx:~/mono/mono-2.6.7$ ls -l /usr/bin/mono
ls: cannot access /usr/bin/mono: No such file or directory

Here is my path:

xxx:~/mono/mono-2.6.7$ echo $PATH

Doesn't it search each directory separated by the colons? So shouldn't it find mono in /usr/local/bin ?

If I log in as root, it works. I can execute mono on the command line and it finds it. The permissions are:

xxx:~/mono/mono-2.6.7$ ls -l /usr/local/bin/mono
-rwxr-xr-x 1 root root 8452592 2010-08-02 16:23 /usr/local/bin/mono

Is the user I am using not part of the right group?

3 Answers 3


Bash keeps a cache of command locations in memory, so that it doesn't have to do the whole PATH exploration each time you start a command. In your original bash session, bash had previously memorized that mono was /usr/bin/mono. Then you removed /usr/bin/mono and added /usr/local/bin/mono, but your running bash still had the old location in its cache.

You can manipulate the command location cache with the hash builtin. In particular hash -r clears the cache.

which is an external command, so it doesn't use bash's cache and performs a PATH lookup every time. You could also have used type, which is a builtin and therefore does use the lookup cache.

  • hash -r worked for me. Good answer! Commented Sep 1, 2014 at 14:24

Maybe you have an alias defined for mono? Check out that the following files in your home directory: .bashrc, .profile, .login or .bash_profile

... does not contain something like this

 alias mono="/usr/bin/mono"

This can also be located in /etc/bashrc or /etc/profile.

Command alias shows all currently defined aliases.

  • Nope. No alias for mono.
    – CShipley
    Commented Aug 2, 2010 at 16:51

I logged out, and then logged in again and it worked. I must have been doing something stupid. But, it works!

  • OK, great to hear that :) Commented Aug 2, 2010 at 17:05
  • A log out and log back in would indeed reset the cache as mentioned by Gilles. Commented Jul 20, 2016 at 0:39

You must log in to answer this question.