如何启动一个没有任何用户configuration的shell?

我需要在Linux / OSXterminal下使用一个干净的shell(例如bash),而不需要任何用户configuration,但是每次启动的时候它都会从一些文件(例如〜/ .bashrc)读取configuration信息。 每次我需要一个“干净的”shell时,我都可以修改这个文件,并在完成时恢复它,但有没有更简单的方法来执行此操作,例如命令?

您可以传递--noprofile--norc命令行选项:

 $ bash --noprofile --norc 

您将在手册页中找到有关这些选项的文档。

运行bash --noprofile --norc仍然继承父进程。 基于类似的问题,我发现我解释这个问题的方式env -i bash --norc --noprofile是我想要的。

使用–noprofile –norc:

  --noprofile Do not read either the system-wide startup file /etc/profile or any of the personal initializa‐ tion files ~/.bash_profile, ~/.bash_login, or ~/.profile. By default, bash reads these files when it is invoked as a login shell (see INVOCATION below). --norc Do not read and execute the system wide initialization file /etc/bash.bashrc and the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh. 

(从联机手册)。