0

Why is it that some bash programs will only run on my system when I type ./ before their name?

An example: In my [...]/android/sdk folders I have to execute adb like this:

./adb devices

Why not just adb devices?

polym
  • 10,672
  • 9
  • 41
  • 65
Eddnav
  • 101
  • 1
  • http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_01.html – Ramesh Jul 02 '14 at 00:49
  • 1
    This has just *got* to be a dupe. – Faheem Mitha Jul 02 '14 at 01:12
  • What is missing from many answers is that this is a _relative path_ made out of a reference the current directory file (.) and the rest of the path from that point, in the context of [pathname resolution](http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html). –  Jul 02 '14 at 01:36

2 Answers2

0

If you run

echo $PATH

you will see a list of directories that your system will search for commands to run.

If you want to run commands in your current working directory, then you can run:

PATH=$PATH:.;export PATH

You can add this line to your ~/.bash_profile to have this behaviour persistent across sessions.

Warwick
  • 1,620
  • 12
  • 16
0

. is the symbol for your current directory. You have to include the / so it knows that it's not a . at the beginning of the file. If you navigate to a different directory and type the directory of the file, you don't have to have the ./

Johnyburd
  • 101
  • 5