When using Bash in Windows Subsystem for Linux (WSL), you may encounter a “.bashrc: permission denied” error. Here are notes on how to fix this error.
Problem Overview
After restarting Windows and opening Bash, the .bashrc file may not be executed. Checking the file permissions with the following command, you’ll find that the permissions have somehow disappeared.
$ ls -al ~
total 124
drwxr-xr-x 1 yuis yuis 4096 Aug 12 07:50 .
drwxr-xr-x 1 root root 4096 Sep 30 2017 ..
drwx------ 1 yuis yuis 4096 Mar 6 00:39 .aptitude
-rw-rw-rw- 1 yuis yuis 28823 Jul 12 22:45 .babel.json
-rw------- 1 yuis yuis 13920 Aug 12 15:03 .bash_history
-rw-r--r-- 1 yuis yuis 220 Sep 30 2017 .bash_logout
---------- 1 yuis yuis 5272 Aug 12 04:32 .bashrc
-rwxr-xr-x 1 yuis yuis 5272 Aug 12 07:50 .bashrc.bak
As you can see, the .bashrc file has lost its permissions, causing the error.
Solution
-
Navigate to Home Directory
cd ~ -
Change .bashrc File Permissions
sudo chmod 755 .bashrc -
Restart Bash
bash
With this, the permissions are correctly set, and you can confirm that .bashrc is loaded normally when opening a new Bash session.
Summary
When the “.bashrc: permission denied” error occurs in WSL Bash after a restart, it’s caused by the .bashrc file losing its permissions. You can fix the problem by correcting the permissions with the steps described above and restarting Bash.