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

The title says it all. I would like to type "run" in the command line and it would execute /pathtoscript/
Thank you!

share|improve this question
up vote 2 down vote accepted

Create a file named run with the contents:

exec /pathtoscript/ "$@"

Place the file in your path and set the executable bit.

What is "your path"?

At the command line, type:

echo $PATH

You will see a colon-separated list of directories. These are the directories that the shell searches when looking for a command to run. They are collectively called the path. You will want to place your new file run in any one of those directories.

Alternate approach for interactive work

If you just want run to work when you are working interactively, you can create an alias:

alias run=/pathtoscript/

If you want this alias saved permanently, put that line in the .bashrc in your home directory.

share|improve this answer
What does "your path" mean? – QuyNguyen2013 Jul 28 '14 at 19:31
If I want it permanently which method should I use? – QuyNguyen2013 Jul 28 '14 at 19:38
@Autospamfighter Both are permanent. There are times when aliases don't work, so using the run file is more robust. – John1024 Jul 28 '14 at 19:41
Thanks! I will try the "run" file. – QuyNguyen2013 Jul 28 '14 at 19:42
You forgot to do #!/bin/sh – QuyNguyen2013 Jul 28 '14 at 20:49

In *nix shells, the way this is done is by adding an executable file (or symbolic link to an executable file) to one of the directories listed in the PATH variable. From a hypothetical session:

$ which foo
which: no foo in (/usr/local/sbin:/usr/local/bin:/usr/bin)
$ foo
bash: foo: command not found
$ echo "$PATH"
$ sudo ln -s /path/to/my/script /usr/local/bin/foo
$ foo
[whatever your script prints]
share|improve this answer
Is the *nix shell standard? Do I need to install anything? – QuyNguyen2013 Jul 28 '14 at 19:36
"*nix" is just a historical shorthand for "Unix-like". It's not something you have to install. – l0b0 Jul 28 '14 at 19:44

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.