I was learning about Common shell programs.
When I run
cat /etc/shells, it shows:
# /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash
/bin/rbash here? Is it used in scripting?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
The restricted shell is a Unix shell that restricts some of the capabilities available to an interactive user session, or to a shell script, running within it. It is intended to provide an additional layer of security, but is insufficient to allow execution of entirely untrusted software. A restricted mode operation is found in the original Bourne shell and its later counterpart bash, and in the Korn shell. In some cases a restricted shell is used in conjunction with a chroot jail, in a further attempt to limit access to the system as a whole.
See Soren A's answer for the limitations that apply to restricted shells.
You can run
bash in restricted mode
bash -r bash --restricted
On my system:
$ file /bin/rbash /bin/rbash: symbolic link to bash
So if I run
/bin/rbash, I am running
It suffices to create a link named rbash pointing directly to bash. Though this invokes bash directly, without the
--restrictedoptions, bash does recognize that it was invoked through rbash and it does come up as a restricted shell.
As you can easily test:
zanna@monster:~$ rbash zanna@monster:~$ cd playground rbash: cd: restricted
rbash is a restricted (reduced capabillities) version of bash. See this article: https://en.wikipedia.org/wiki/Restricted_shell
From the article:
The following operations are not permitted in a restricted shell:
changing directory specifying absolute pathnames or names containing a slash setting the PATH or SHELL variable redirection of output
bash adds further restrictions, including:
limitations on function definitions limitations on the use of slash-ed filenames in bash builtins
Restrictions in the restricted Korn shell are much the same as those in the restricted Bourne shell.