Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I am experimenting with Django develpment in virtualenv. It is rather anyoing that each time I should type commands like:

python runserver

I am wondering what should I do to run the same command without 'python', i.e. just: runserver
share|improve this question
possible duplicate of run python in terminal – Eliah Kagan Sep 10 '14 at 0:39

You can set the file to be executable with chmod +x and then execute it with ./ runserver.

Note that if you create your own script files you will have to include the UNIX shebang in the file.

share|improve this answer
I am so lazy so trying to avoid ./ too. :) – wbad Oct 18 '13 at 10:29
Isn't there a way to ditch ./ ? – wbad Oct 18 '13 at 10:42
You're approaching this from the wrong angle. Any decent shell will support autocompletion by hitting the tab key. Telling the shell you want to limit your autocompletion choices to the current directory by using ./ is a good thing and makes it much faster to complete the filename you were looking for. In the case of Django's file I type './m' and hit tab. Boom. – eagleflo Oct 18 '13 at 10:48
@wbad check my answer which is for the lazy. – don.joey Oct 23 '13 at 14:08

Try to create an alias in your bashrc file like
alias python='p'
after that execute it using
p runserver

share|improve this answer
Please elaborate on your answer. – guntbert Oct 18 '13 at 14:15

If you really must do away with the ./ there is a way.

There are certain paths that python will look to run a file.

Place a file in usr/local/bin and make sure it is executable. Then you can run it by just typing the name. That is because usr/local/bin is a directory that Python check for executables.

Thats the extent of my knowledge. For more useful info you will want to figure out how to view the PYTHONPATH variable so you know what directories this works for. Also there is a way to add a directory to this variable so you can add a directory with all your py scripts.

I don't know how to do this off the top of my head, and I'm sure you can Google as well as I can.

share|improve this answer

I use the following django related aliases in order to type less:

alias pm='python'
alias rs='python runserver'
alias goprojectname ="workon projectname; cdvirtualenv; cd projectfolder; rs"

You can put them in your .bashrc or .bash_aliases (preferably). I can just type rs to get runserver working or, for instance, pm syncdb to sync the database.

Here is how to create permanent aliases.

share|improve this answer

A lazy trick - just add #/usr/lib/python on the first line of your Python app, and make it executable using the chmod trick above, and double click it and it should work, or in the terminal,
./ runserver
Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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