Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 have a few python scripts on /usr/share/scripts/ that I use often, and I want to be able to execute them by just writing the name and not the full path, how could I do this?

echo $PATH shows me:


So I tried writing on the terminal:


No errors shown and echo $PATH now shows my new scripts path, but when I run scriptName I get command not found.

What am i doing wrong?

share|improve this question
How did you do it right before? – Ignacio Vazquez-Abrams May 12 '11 at 12:06
I didn't do it before. – grerdas May 12 '11 at 12:08
You didn't run them? I thought you said you used them often... – Ignacio Vazquez-Abrams May 12 '11 at 12:11
@Ignacio Vazquez-Abrams : Oh I didn't understand your question sorry, I ran them like "/usr/share/scripts/ args" – grerdas May 12 '11 at 12:12

Set executable permissions for python scripts by "chmod +x *"
Now you have two options:

  • Add your scripts directory to PATH env variable, or
  • Make symbolic links to your scripts one by one (or write another script to do the same) in /usr/local/bin directory.

[mzed@node02 test]$ vim

Contents of file:

print "This is cool!"


[mzed@node02 test]$ mv printme
[mzed@node02 test]$ chmod +x printme
[mzed@node02 ~]$ cd /usr/local/bin/
[mzed@node02 bin]$ sudo ln -s ~/test/printme .
[mzed@node02 bin]$ ls
deskzilla  grails  grails-debug  printme  startGrails
[mzed@node02 bin]$ cd
[mzed@node02 ~]$ printme 
This is cool!
[mzed@node02 ~]$

I hope this will help you.

share|improve this answer
Any possibility to make a version for Windows? (I know this is a Linux question) – Iulian Onofrei Mar 20 '15 at 20:02

Okay, maybe I'm just older school...
In /usr/bin add shell scripts with the #!/bin/bash header and no .sh extension. Then in those scripts just run python absolutepath.

Why I think it's better than the other answers:
Doesn't require chmod-ing your scripts to make them executable.
Doesn't require renaming your scripts.

share|improve this answer
Don't forget the args. – juanitogan Jan 13 at 6:02

Sorry for suggesting a basic thing.. Did you try "", instead of just "scriptname"?

Also, all the scripts need to have execute permissions (you can do that by issuing "chmod +x").. Judging from your comment above, since you have run them like "/usr/share/scripts/ args", they should have execute permissions.

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.