What exactly is the sh command?

34

15

I can't figure out what the sh command is?

http://unixhelp.ed.ac.uk/CGI/man-cgi?sh

Does it execute a file?

like in tomcat:

sh /usr/local/tomcat/bin/shutdown.sh

Sorry, just confused.

user3183

Posted 2010-01-18T18:14:33.483

Reputation: 3 059

"In Ubuntu 6.10, the default system shell, /bin/sh, was changed to dash (the Debian Almquist Shell); previously it had been bash (the GNU Bourne-Again Shell)."—https://wiki.ubuntu.com/DashAsBinSh . dash is a little quicker than bash

– noobninja – 2020-01-11T20:51:43.843

1@Chopper3: tags aren't for expressing your opinion, comments are. – ThatGraemeGuy – 2010-01-18T18:56:43.760

Answers

34

sh is the bourne shell.

There are several shells, of which bourne is the old standard, installed on all unix systems, and generally the one you can guarantee will exist.

The shell is the command interpreter that takes your input, provides output back to the screen, to the correct files, etc, and provides all the basic built-in commands you need to manage jobs, kill, test expressions, etc.

Your command above is saying to run that shell-script using the bourne shell. Different shells use different syntax, so using the correct shell is a requirement. The first line of the shell should also define which to use: #!/bin/sh says use /bin/sh

Alex

Posted 2010-01-18T18:14:33.483

Reputation: 543

3On many systems (like in Mac OS X), nowadays sh is actually bash, aka the Bourne-again shell. The command sh --version will tell one more. It's backwards compatible with the Bourne shell though. – Arjan – 2010-01-19T06:32:25.560

7

sh is the bourne shell. /usr/local/tomcat/bin/shutdown.sh is a shell script. sh file runs file as a shell script. generally one would just set the execute bit and run ./file.

user23307

Posted 2010-01-18T18:14:33.483

Reputation: 5 915

ok so I am going out and changing my shell implicitly to run that command, ok thanks. – user3183 – 2010-01-18T18:23:15.833

Techinically, you would be changing the script.

Make sure the first line is:

#!/bin/bash

then:

chmod +x /usr/local/tomcat/bin/shutdown.sh

to make it executable – None – 2010-01-18T18:28:41.923