How do I make a new command to run a script, for example if I type runme (from any dir) it will run /run/me/script.sh? Seems simple but I can find anywhere that explains how to do this :/


simply add /run/me to your PATH, any script put there could be simply run from any directory

how to PATH from troubleshooters.com
To add directory /data/myscripts to the beginning of the $PATH environment variable, use the following:


To add that directory to the end of the path, use the following command:



export PATH

to have it everywhere, all the times, for your user only, add these in place the lines in that user's .bash_profile file
all users except root: add to /etc/profile
for root: only possible by root's .bash_profile

my idea for the sake of laziness (not your case of running 'every' script though): add a symbolic link from a single script there to your /home/usr/loca/bin


Two possiblities:

  1. alias runme='/run/me/script.sh' at the bash command prompt. This works for this session only. Put this line in ~/.bashrc if you want this change to be persistent.

  2. rename script.sh to runme and add /run/me to the PATH


P.S.: Make sure script.sh has executable rights (chmod +x script.sh)

  • Huh? I need it run from any directory.. My friend has stuff installed on the server in /usr/local/svn/usr/local/bin/ which I run scripts from by typing a_script_in_that_dir , but that is not my home dir, I tried putting a script into there to see if it would work but it didn't :/ – Goulash Mar 25 '12 at 1:01
  • If you type echo $PATH from the command line you will see all the directories (such as /usr/local/) that the shell looks for programs in. That is one method (#2 above). The other method addresses naming a script one thing, but calling it from the command line as another (aliasing) – Huckle Mar 25 '12 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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