Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
What does “/” , “./”, “../” represent while giving path?

Example: For running a django server I use: python manage.py runserver

But some people seem to use ./manage.py runserver. This command seems to do the same as the previous one.

What exactly does the ./ part do?

share|improve this question

marked as duplicate by slhck Dec 13 '12 at 11:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

up vote 4 down vote accepted

. is the path of the current directory.
Every directory always have two special files, ., and .., where first represents itself, while second represents the parent directory.

By writing ./manage.py runserver, you are running command manage.py with argument runserver. To see what happens when you execute manage.py, check what is the content of the file with less manage.py.

To sum it up, there shouldn't be any difference in both cases, unless the python version stated in the manage.py is different than the default python version. The python used in manage.py can be seen at the first line.

share|improve this answer
    
Ok, so the first line of manage.py is #!/usr/bin/env python. ./file will always execute the file the binary provided by that path. So it's just better to write ./ then python because it's shorter. Correct? –  Bentley4 Dec 13 '12 at 11:31
    
Bentley, you still don't appear to understand. It's not something you should bear in mind specific to Python. Check my answer. –  deed02392 Dec 13 '12 at 11:37
    
Off Course, I just meant in this case but I guess I could've written it more clearly sorry. Could you explain why running python manage.py doesn't require manage.py to have executive permission while ./manage.py does? –  Bentley4 Dec 13 '12 at 11:47
1  
Sure, the reason is that running 'python manage.py' doesn't need executive permission on manage.py is : In this case, manage.py is just an argument to command python. –  bbaja42 Dec 13 '12 at 11:54

The ./ tells the shell that you are referring to a file in the current directory. If you wanted to call a program such as backup and this happened to be a binary available in one of the program directories on the system, the shell would by default run this binary.

However you might have been in a directory of your own programs which happened to have a binary called backup, too. You might hence not even realise that the system was actually running a completely different binary.

By using ./backup, you are specifying that you want the system to use the binary in the current working directory, as opposed to one available in the program dirs.

You can test this by using the Linux whereis command, which in this example might specify that backup is actually at /usr/bin/backup, instead of perhaps ~/backup.

share|improve this answer

The main reason for the use of ./ prefix is that the current directory is not in the $PATH variable. At least it shouldn't be, like in windows, where you have a ;. at the end of the PATH.

share|improve this answer

./ is a short hand method of doing an operation from the current directory.

../ is a short hand method of going "up" a folder before entering the folder name given.

share|improve this answer
2  
What do you mean with 'root line'? Operating from the / (root) directory? This doesn't make any sense to me because there is no manage.py file in my / directory. –  Bentley4 Dec 13 '12 at 11:18
    
@Bentley4 ./ means the current directory. See the other answers to this and the linked question for details. –  Indrek Dec 13 '12 at 12:29
    
Sorry, root was a bad word choice. Thank you @indrek Too many "project roots" :( –  Avik Dec 13 '12 at 13:01

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