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?

  • 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. Dec 11, 2015 at 9:13

2 Answers 2


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).


Put the script in your bin directory.

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