SoFunction
Updated on 2025-03-09

Solve the problem of bash:/root/.bashrc:Permission denied

This is the permissions issue for the file:

You can check the file permissions:

root@0d71811f7c01:/usr/local/src# ls -al  ~/
total 32
drwx------ 1 root root 4096 Nov 17 23:34 .
drwxr-xr-x 1 root root 4096 Nov 10 14:57 ..
-rw------- 1 root root  523 Nov 17 23:34 .bash_history
-rwSr-Sr-- 1 root root  570 Jan 31  2010 .bashrc
drwx------ 3 root root 4096 Nov 17 15:25 .cache
-rw-r--r-- 1 root root  126 Nov  3 14:57 .gitconfig
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw-r--r-- 1 root root  165 Feb  2  2020 .wget-hsts

It was found that the .bashrc file does not have permission to execute;

So the operation is as follows:

chmod 766 ~/.bashrc
root@0d71811f7c01:/usr/local/src# ls -al  ~/
total 32
drwx------ 1 root root 4096 Nov 17 23:34 .
drwxr-xr-x 1 root root 4096 Nov 10 14:57 ..
-rw------- 1 root root  523 Nov 17 23:34 .bash_history
-rwxrw-rw- 1 root root  666 Nov 18 11:57 .bashrc
drwx------ 3 root root 4096 Nov 17 15:25 .cache
-rw-r--r-- 1 root root  126 Nov  3 14:57 .gitconfig
-rw-r--r-- 1 root root  148 Aug 17  2015 .profile
-rw-r--r-- 1 root root  165 Feb  2  2020 .wget-hsts

In this way, the .bashrc file has permission to execute;

Because I am an administrator, 766 only gives the administrator permissions to execute. If you are not an administrator, you can change it to 777 directly. However, it is recommended that it is best to restore the original permissions after execution, which is safer.

This is the article about solving the problem of bash:/root/.bashrc:Permission denied. For more related bash: permission content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!