Linux And Friends
Linux, Open Source, Free Software, Bicycles, and other topics of interest.
-
Opening bash shell in restricted mode
Posted on September 7th, 2008 No commentsA 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--restrictedor-roption 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
cdcommand. - 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
hashbuiltin 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
execbuilt-in to replace the shell with another command. - Adding or deleting built-in commands with the -f and -d options to the
enablebuilt-in. - Using the
enablebuilt-in command to enable disabled shell built-ins. - Specifying the -p option to the
commandbuilt-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,
rbashturns off any restrictions in the shell spawned to execute the script.Related Posts
- How to Install GNOME Shell in Ubuntu Linux
- GNOME Shell – An Overview
- Google Shell – Goosh
- pngcrush – Image Optimizer for PNG Graphics
- A command line twitter app in your web browser
- You can’t change directories using










