Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

After creating a Python script file, test.py, in my home directory, and running chmod +x test.py to make it executable, and placing #!usr/bin/env as the file header, I expected to be able to run the script from bash on OS X, using:

$ test.py

but bash returned:

-bash: test.py: command not found

The following command worked:

$ ./test.py

Why is the relative path required for this executable script in the present working directory?

share|improve this question

marked as duplicate by manatwork, warl0ck, vonbrand, Ulrich Dangel, Mat Mar 24 '13 at 14:30

This question was marked as an exact duplicate of an existing question.

up vote 0 down vote accepted

The shell searches the execute path ($PATH) for programs when you give it a command to run. Pre-fixing a command with a path, such as ./ prevents the shell from searching and instructs the shell to use a specific program, explicitly specified.

If a program resides in a directory not in the search path then you have to explicitly indicate the path to the program.

share|improve this answer

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