I was editing the bashrc script in my Windows 10 Ubuntu Bash and I made a mistake while editing the script. Now bash exits immediately upon opening it. Is there a way for me to open Bash without running bashrc, or will I have to reinstall it?

  • 2
    Why not just edit .bashrc from any Windows App such as Notepad++ ? – Carl Witthoft Jul 8 at 13:12
  • 4
    @CarlWitthoft I believe you can't (shouldn't?) edit WSL files from Windows (but you can do it the other way around). – Martin Jul 8 at 14:29
  • I believe that it is safe to rename WSL files from Windows — so just rename .bashrc to .bashrc.hold. Or is that dangerous too? – G-Man Jul 8 at 15:29

You should be able to skip loading the default .bashrc file in WSL in essentially the same way as in "regular" bash:

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

So, open the Windows CMD.exe and type

wsl.exe -e bash --norc

Once you are in the interactive shell you can revert the changes yo made to the ~/.bashrc file.

  • CMD? Why not PowerShell? Not perfect, but way better than cmd. – jpmc26 Jul 8 at 15:06
  • 5
    @jpmc26 - Because in this situation, it doesn't matter, both work and the result is the exact same, but cmd is faster to load and easier to open with purely keyboard commands – Taegost Jul 8 at 15:46
  • 1
    There's no need to open a prompt first at all, you can simply hit the windows key and type "wsl -e bash --norc" followed by enter. – SoronelHaetir Jul 8 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.