When I issue alias --help I get this output:

alias: usage: alias [-p] [name[=value] ... ]

As I understand, all you need to do is to type an alias and provide the actual path to the script file, like this:

alias scr = /usr/local/tools/some_script.sh

However, I noticed that sometimes 2 paths are being provided when creating aliases - for example, I issued alias scr command on a corporate machine and got this output:

alias scr = 'sudo /bin/sh /usr/local/tools/some_script.sh'

What is the purpose of introducing additional path /bin/sh in this case?

The /bin/sh contains only a symlink to bash directory:

ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Aug  6  2017 /bin/sh -> bash
  • 1
    An alias replaces one string with another string before the command is interpreted further. It's purely textual. The replacement string can even include |, ; or #. Your question might be "why /bin/sh /usr/local/tools/some_script.sh and not just /usr/local/tools/some_script.sh?" The fact these strings may come from an alias is irrelevant. Don't think of an alias as of providing one or more paths. It provides a string. Upon further interpretation some substrings may turn out to be command(s) with options and/or (option-)arguments, possibly in form of paths. May 24, 2020 at 18:22
  • @ctrl-alt-delor calm down, maggot
    – kamokoba
    May 25, 2020 at 7:46
  • You say "and got this output" -- No you did not. Did you re-type it with the extra spaces. May 25, 2020 at 10:32

1 Answer 1


The alias defined through

alias scr='sudo /bin/sh /usr/local/tools/some_script.sh'

(having spaces around the = is an error), calls sudo which in turn runs the script /usr/local/tools/some_script.sh by explicitly calling the /bin/sh shell interpreter with the script's pathname as an argument.

The /bin/sh is the pathname of the sh executable under /bin (in your case it's a symbolic link to bash, but that's unimportant). It is used to run sh shell scripts. In this case, the script at /usr/local/tools/some_script.sh is presumably a script written for sh, so the alias makes sure that it's called with /bin/sh as the interpreter.

If the script is executable and has a #!-line that points to a valid script interpreter as its first line, the /bin/sh bit can be removed.

So, in short, the alias allows you to run the command

/bin/sh /usr/local/tools/some_script.sh

as root by just typing scr.

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.