Restricted shell

The restricted shell is used to set up login names and execution environments whose capabilities are more controlled than those of the regular Bourne shell.

The Rsh or bsh -r command opens the restricted shell. The behavior of these commands is identical to those of the bsh command, except that the following actions are not allowed:

  • Changing the directory (with the cd command)
  • Setting the value of PATH or SHELL variables
  • Specifying path or command names containing a slash (/)
  • Redirecting output

If the restricted shell determines that a command to be run is a shell procedure, it uses the Bourne shell to run the command. In this way, it is possible to provide a user with shell procedures that access the full power of the Bourne shell while imposing a limited menu of commands. This situation assumes that the user does not have write and execute permissions in the same directory.

If the File [Parameter] parameter is specified when the Bourne shell is started, the shell runs the script file identified by the File parameter, including any parameters specified. The script file specified must have read permission. Any setuid and setgid settings for script files are ignored. The shell then reads the commands. If either the -c or -s flag is used, do not specify a script file.

When started with the Rsh command, the shell enforces restrictions after interpreting the .profile and /etc/environment files. Therefore, the writer of the .profile file has complete control over user actions by performing setup actions and leaving the user in an appropriate directory (probably not the login directory). An administrator can create a directory of commands in the /usr/rbin directory that the Rsh command can use by changing the PATH variable to contain the directory. If it is started with the bsh -r command, the shell applies restrictions when interpreting the .profile files.

When called with the name Rsh, the restricted shell reads the user's .profile file ($HOME/.profile). It acts as the regular Bourne shell while doing this, except that an interrupt causes an immediate exit instead of a return to command level.

The Korn shell can be started as a restricted shell with the command ksh -r.

The inodes for ksh and rksh are identical, and the inodes for ksh93 and rksh93 are identical.