How to start a shell without any user configuratio

2019-03-08 13:37发布

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?

3条回答
smile是对你的礼貌
2楼-- · 2019-03-08 14:13

Running bash --noprofile --norc still inherited from parent process. Based on a similar question I found that the way I interpreted this question env -i bash --norc --noprofile was what I would want.

查看更多
聊天终结者
3楼-- · 2019-03-08 14:15

You can pass the --noprofile and --norc command-line options:

$ bash --noprofile --norc

You will find documentation about these options in the man page.

查看更多
爷、活的狠高调
4楼-- · 2019-03-08 14:15

Use --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).

查看更多
登录 后发表回答