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 learning python from learnpythonthehardway. In Windows I had no issues with going through a lot of the exercises because the setup was easier, but I want to learn Linux as well and Ubuntu seemed to me the nicest choice.

Now I am having trouble with setting up. I can get access to the terminal and then /usr/lib/python.2.7, but I don't know if I should save the script in this directory? If I try to make a directory inside this through mkdir I can't as permission is denied. I also tried to do chmod but didn't know how or if to do it.

How can I correctly save my script? I would like to be able to run the script like this: user@user$ python and have it work.

I'm using Ubuntu 12.04.

share|improve this question
up vote 2 down vote accepted

You can save your code in your home directory - normally /home/(your username)/ or ~/ for short. Once you've saved your code you should be able to call it from python by using

$ python ~/myCode/

if your code was in a folder called myCode (also note that folder & file names are case sensitive)

You don't need to be in the directory /usr/bin/ to run python as that folder is part of your $PATH - which means it's accessible no matter which folder you're in.

You may also want to use IDLE, a commonly used GUI for python. You can install it by searching in the Software Center or by running

$ sudo apt-get install python-idle

share|improve this answer
thanks. really helped. I was actually making the files in desktop than in the home directory... – user1837259 Nov 20 '12 at 0:31
The desktop is within your home directory :) – Marcin Kaminski Nov 20 '12 at 1:25

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.