Linux, Open Source, Free Software, Bicycles, and other topics of interest.
RSS icon Twitter icon
  • Opening bash shell in restricted mode

    Posted on September 7th, 2008 linuxandfriends No comments

    A restricted shell is used to set up an environment more controlled than the standard shell.Bash shell can be opened in restricted mode. If bash shell is started with the name rbash, or the --restricted or -r option is supplied at invocation, it is opened as a restricted shell.

    The following commands will open a bash shell in restricted mode.

    $ bash --restricted

    OR

    $ rbash

    OR

    $ bash -r

    Characteristics of a restricted mode bash shell

    A restricted shell behaves identically to bash with the following exceptions.

    • You can’t change directories using cd command.
    • Set or unset environment variables. Eg: SHELL, PATH, ENV etc.
    • Specify command names containing slashes.
    • Specify a filename containing a slash as an argument to the .(dot) built-in command.
    • Specifying a filename containing a slash as an argument to the -p option to the hash builtin command.
    • Importing function definitions from the shell environment at startup.
    • Parsing the value of SHELLOPTS from the shell environment at startup.
    • Redirecting output using the ‘>’, ‘>|’, ‘<>’, ‘>&’, ‘&>’, and ‘>>’ redirection operators.
    • Using the exec built-in to replace the shell with another command.
    • Adding or deleting built-in commands with the -f and -d options to the enable built-in.
    • Using the enable built-in command to enable disabled shell built-ins.
    • Specifying the -p option to the command built-in.
    • Turning off restricted mode with ‘set +r’ or ‘set +o restricted’ .

    These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script.

    http://linuxandfriends.com/wp-content/plugins/sociofluid/images/digg_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/reddit_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/stumbleupon_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/delicious_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/google_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/myspace_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/facebook_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/yahoobuzz_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/mixx_48.png http://linuxandfriends.com/wp-content/plugins/sociofluid/images/twitter_48.png

    Related Posts

    Comments are closed.