So I was working with Bash on Unbuntu on Windows in order to learn Linux, so I attempted to edit the .bashrc file as a way of learning. To do this I went into the root folder in my C: drive and opened the .bashrc in VS Code. I added one line into the end of the file.

When I tried to run ubuntu I got this error (even though it still works), and the error still persists even after I went in to try undo what I did before. What is wrong?

  • Sounds like a permission problem. Can you try to do sudo chmod 644 /home/user/.bashrc and see if that helps. – Mikael Kjær May 2 '18 at 4:51
  • @Biswapriyo Why didn't you make that edit yourself? – DavidPostill May 2 '18 at 7:55
  • @MikaelKjær Would be helpful if this was posted as an answer; your comment worked for me. – Stardust Nov 27 '18 at 2:28

What is wrong?

As you mentioned that you went to root folder in C: drive and opened .bashrc in VSCode, I am assuming that the VSCode you just used was installed on Windows, not on WSL. Now I would like to refer you to a blog post on the official blog of Microsoft that explains the exact situation that you have encountered. This will help too.

To revert the changes, I would suggest you to open the .bashrc in the same way you did previously and copy all its content to a different file say, on your desktop. Remove .bashrc file. Now open a text editor in WSL preferably vim or gedit, make a file with name .bashrc, save it in the home directory and copy all the text that you saved on your desktop to the new .bashrc and it is all done.

| improve this answer | |

Once started the shell and you see this error, "reset" the permission(s) of that file(s).

Try this

1) Go there cd /home/{USER}/ and

2) Change permission chmod 644 .bashrc


1) For me it was working without sudo

2) 644 means writable, readable and executable for the user and readable for groups and others

I had this issue because I edited some .bash*** files with Notepad++ on Windows. After saving the files there were not executable anymore with Ubuntu.

Instead of copying, saving, re-creating the changes, like @DeusExMachina mentioned, I wanted to see what just happened with the file permissions there.

I went into my home directory and checked the Permissions of each file and I saw that my edited files .bashrc and .bash_aliases now had permissions of 000 - so they got locked by Windows!

I changed the permissions for my edited files from 000 to 644 and it was working again.

| improve this answer | |
  • Don't forget the line endings. It needs to be converted to Unix style also. – mr5 Jul 5 at 16:50

I had this exact issue. To solve it, I simply used sudo chmod -R 777 /home/user/.bashrc and it worked.

| improve this answer | |

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.