Linux 如何在没有任何用户配置的情况下启动 shell?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9357464/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to start a shell without any user configuration?
提问by lil
I need to use a "clean" shell (e.g. bash) under Linux/OSX terminal without any user configuration, but it reads config info from some files (e.g ~/.bashrc) every time it starts. I can modify the file every time I need a "clean" shell, and revert it back when I finished, but is there any easier ways to do this, for example a command?
我需要在没有任何用户配置的情况下在 Linux/OSX 终端下使用“干净”的 shell(例如 bash),但它每次启动时都会从某些文件(例如 ~/.bashrc)中读取配置信息。每次我需要一个“干净”的外壳时,我都可以修改文件,并在我完成后将其还原,但是有没有更简单的方法来做到这一点,例如命令?
采纳答案by Frédéric Hamidi
回答by user unknown
Use --noprofile --norc:
使用 --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.
(from the manpage).
(来自联机帮助页)。
回答by nnutter
Running bash --noprofile --norc
still inherited from parent process. Based on a similar questionI found that the way I interpreted this question env -i bash --norc --noprofile
was what I would want.
运行bash --noprofile --norc
仍然继承自父进程。基于一个类似的问题,我发现我解释这个问题的方式env -i bash --norc --noprofile
正是我想要的。