sh – Shell Command Interpreter

The sh command, also known as the shell command interpreter, is a command-line program in Linux that interprets and executes commands entered by the user in the terminal. The shell acts as an interface between the user and the operating system, allowing users to interact with the system by typing in commands. The sh command is the default shell for many Linux distributions, including Ubuntu, Debian, and CentOS.


To use the sh command, simply open up a terminal and type in your command. The shell will interpret the command and execute it. The sh command is often used to run shell scripts, which are files containing a series of commands that can be executed as a single unit.

Here are some examples of how to use the sh command:

  • To run a shell script called, type sh in the terminal.
  • To start an interactive shell session, simply type sh in the terminal. This will open up a new shell session, allowing you to enter commands and interact with the system.
  • To run a single command, such as ls, type sh -c "ls" in the terminal.


The sh command has several options that can be used to modify its behavior. Here are some of the most commonly used options:

Option Description
-c Executes the command that follows the option
-e Exits immediately if a command exits with a non-zero status
-n Reads commands but does not execute them
-u Treats unset variables as an error
-v Prints each command before executing it

Troubleshooting tips

Here are some common issues that users may encounter when using the sh command:

  • If you receive a “permission denied” error when trying to run a shell script, make sure that the script has execute permissions. You can grant execute permissions by typing chmod +x in the terminal.
  • If you are having trouble with a shell script, try running it with the -x option to enable debug mode. This will print each command as it is executed, allowing you to see where the script is failing.
  • If you are encountering errors with a particular command, try running it with the -n option to see what the shell would do without actually executing the command.


  • The sh command is just one of several shell options available in Linux. Other popular shells include bash, zsh, and fish.
  • The sh command is often used in shell scripts, which can be used to automate tasks and simplify complex command sequences.