什么是/ bin / rbash?

我正在学习Common shell程序 。

当我运行cat /etc/shells ,它显示:

 # /etc/shells: valid login shells /bin/sh /bin/dash /bin/bash /bin/rbash 

什么是/bin/rbash ? 它是用于脚本编写的吗?

来自维基百科

受限shell是一个Unix shell,它限制了交互式用户会话或在其中运行的shell脚本可用的一些function。 它旨在提供额外的安全层,但不足以允许执行完全不受信任的软件。 在原始的Bourne shell [1]及其后来的对应bash,[2]和Korn shell中可以找到限制模式操作。[3] 在某些情况下,受限制的shell与chroot jail一起使用,以进一步限制对整个系统的访问。

请参阅Soren A的答案 ,了解适用于限制炮弹的限制。

您可以在受限模式下运行bash

 bash -r bash --restricted 

在我的系统上:

 $ file /bin/rbash /bin/rbash: symbolic link to bash 

所以,如果我运行/bin/rbash ,我正在运行bash

只需创建一个名为rbash的链接就可以直接指向bash。 虽然这直接调用bash,但没有-r--restricted选项,bash确实认识到它是通过rbash调用的,它确实是一个受限制的shell。

您可以轻松测试:

 zanna@monster:~$ rbash zanna@monster:~$ cd playground rbash: cd: restricted 

rbash是bash的限制(减少的能力)版本。 请参阅此文章: https : //en.wikipedia.org/wiki/Restricted_shell

来自文章:

受限shell中不允许执行以下操作:

 changing directory specifying absolute pathnames or names containing a slash setting the PATH or SHELL variable redirection of output 

bash增加了进一步的限制,包括:

 limitations on function definitions limitations on the use of slash-ed filenames in bash builtins 

受限制的Korn shell中的限制与受限制的Bourne shell中的限制大致相同。