The first key point is that ./
specifies the current or working directory, that is, the directory that you are in now which is also the one that you see if you type the command pwd
(print working directory). Bearing that in mind, bash works two ways:
If you specify a bare executable, such adb
where no directory is given, then bash searches along the directories listed in the system PATH for an executable of that name and executes the first such executable that it finds.
To see what directories are in the system PATH, run
echo $PATH
If you specify an executable with a directory, such as ./
in your case, then bash looks only for an executable in that directory. If it is not there, it stops with an error.
In your case, you were in the DEV/ADT/sdk/platform-tools
folder where the executable, adb
, was located. So, when you type ./adb
, bash looks for adb
in the current directory and, if it finds it, it executes it.
Alternatively, when you type adb
, bash looks through the directories in the PATH. Since DEV/ADT/sdk/platform-tools
is apparently not in the PATH, it doesn't find the executable and complains.
Often, people avoid this problem by putting the current directory in their PATH via something like:
PATH="$PATH:."
After this is done, when you type the bare executable's name, such as adb
, bash will look for it, as before, along the PATH. But since the PATH now includes the current directory, it will look there also.
The addition of .
to the PATH is commonly done for personal users. Because it is more dangerous when root accidentally runs the wrong executable, this is usually not done for root.