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

This question already has an answer here:

I am using sage a math library in python. After downloading its package, I usually have to go to the directory where I extracted it and then run the the script using

sudo ./sage

from terminal. How can I add sage to the list of installed applications, that I will be able to run the script by typing sage command from any directory in terminal?

share|improve this question

marked as duplicate by Lucio, Eric Carvalho, Ravan, Charles Green, David Foerster Dec 11 '15 at 9:13

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.

Is there a particular reason, why you run a mathematical application with super-user privileges? I doubt that's necessary and you should avoid that. – David Foerster Dec 11 '15 at 9:13
up vote 7 down vote accepted

You'll need to add that scripts directory to your PATH variable. This can become tedious if you download a lot of self-contained executables. My recommendation would be to create a bin folder in your home folder and place all your self-contained executable files in there.

Most recent versions of Ubuntu already have their PATH setup to read from $HOME/bin so it'll work after a restart of the terminal or after you type source ~/.profile. Once that's completed you should be able to just enter sage in to the terminal.

If you wanted to add another directory, other than ~/bin, you can open the .profile file in your home directory and add the following line to the bottom:


Replacing /path/to/folder with the absolute path to the directory you wish to add. That will prepend the directory of your choice to your PATH environment and it'll take effect once you enter source ~/.profile (or restart the terminal).

share|improve this answer

Put the script in your bin directory.

share|improve this answer

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