Linux / Unix sh command

Quick links

About sh
Syntax
Examples
Related commands
Linux / Unix main page

About sh

Runs or processes jobs through the Bourne shell.

Syntax

sh [-a] [-c] [-C] [-e] [-E] [-f] [-h] [-i] [-I][-k] [-m] [-n] [-p] [-r] [-s] [-t] [-T] [-u] [-v] [-x] [ argument ]

-aExport all variables assigned to.
-cPass the string argument to the shell to be interpreted as input. Keep in mind that this option only accepts a single string as its argument, hence multi-word strings must be quoted.
-CDon't overwrite existing files with ``>.''
-eIf not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explic- itly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an ``&&'' or ``||'' operator.
-EEnable the built-in emacs command line editor (disables -V if it has been set).
-fDisable pathname expansion.
-hMakes all commands use tracked aliases.
-iForce the shell to behave interactively.
-IIgnore EOF's from input when interactive.
-ktells the shell to use Korn-compatible behavior in any case where the POSIX.2 behavior is different from the behavior specified by Korn. In particular, this affects the trap command.
-mTurn on job control (set automatically when interactive).
-nIf not interactive, read commands but do not execute them. This is useful for checking the syntax of shell scripts.
-pTurn on privileged mode. This mode is enabled on startup if either the effective user or group id is not equal to the real user or group id. Turning this mode off sets the effective user and group ids to the real user and group ids. Also on interactive shells and when enabled, this mode sources /etc/suid_profile (in- stead of ~/.profile) after /etc/profile and ignores the contents of the ENV variable.
-rInvokes a restricted shell. In a restricted shell, you cannot do any of the following: use the cd command; change the values of the variables env, path or shell; use > or >> to redirect output; specify command names containing /. These restrictions do not apply during execution of profile files.
-sRead commands from standard input (set automatically if no file arguments are present). This option has no effect when set after the shell has already started running (i.e. with set).
-tExits after reading and executing one command.
-TWhen waiting for a child, execute traps immediately. If this option is not set, traps are executed after the child exits, as specified in IEEE Std1003.2 (``POSIX'') This nonstandard option is useful to put guarding shells around childs that block signals. The surrounding shell may kill the child or it may just re- turn control to the tty and leave the child alone.
-uWrite a message to standard error when attempting to expand a variable that is not set, and if the shell is not interactive, exit immediately.
-vThe shell writes its input to standard error as it is read. Useful for debugging.
-VEnable the built-in vi command line editor (disables -E if it has been set).
-xWrite each command to standard error (preceded by a '+ ') before it is executed. Useful for debugging.

Examples

sh - Executes the Bourne shell, likely taking you to a $ prompt.

Related commands

bc
kill
ksh
login
newgrp
ps
pwd
stty