Solution: bash: /root/.bashrc: Permission denied

This is a file permission issue:

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 is found that the .bashrc file has no execution authority;

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 execution authority;

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

 

Guess you like

Origin blog.csdn.net/chuancheng_zeng/article/details/109784420