How can I run a program without cd'ing to the directory where it resides?

I have tried ./my/dir myfile.pl and again without the leading . but neither work.


You enter the full path of the executable:

  • The file will still be ran from the directory you are currently in. keep that in mind. – UtahJarhead Oct 3 '12 at 18:15

Two dots solves the problem, one dot generates an error (on debian at least) as in the example below:


  • 1
    Two dots do not 'solve the problem'. The dot refers to the current directory, two dots refer to the parent; they are different paths, one of which may or may not be the one you seek. Depending on the current directory, your example may work, but I believe you're looking for the more general /usr/local/bin/myprogram. – Marcks Thomas Nov 18 '13 at 14:57
  • 1
    whatever directory i am in, one dot 'generates a bash' error! – BurakT Nov 18 '13 at 15:38

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.