[Solved] su: warning: cannot change directory to : Permission denied ;-bash: bash_profile: Permission denied

A. Check if the home directory permissions are right

1: Problem description
[root@ser6-52 ~]# su – mongodb
su: warning: cannot change directory to /home/mongodb: Permission denied
-bash: /home/mongodb/.bash_profile: Permission denied

2: Cause of error
The home directory has the wrong owner and insufficient permissions
[root@ser6-51 ~]# ls -ld /home/mongodb/
drwx—— 2 504 504 4096 Jul 15 13:50 /home/mongodb/

3: Solution
Modify the owner,modify the permissions
[root@ser6-51 ~]# chown -R mongodb:mongodb /home/mongodb/
[root@ser6-51 ~]# chmod -R 755 /home/mongodb/
[root@ser6-51 ~]# su – mongodb
[mongodb@ser6-51 ~]$
Now you can switch. ls-ld/home/mongodb/

 

II. View

In fact, it is to use root to modify /etc/sysconfig/selinux, SELINUX=targeted modified to SELINUX=permissive

Third, modify the permissions of the etc directory

chmod -R 755 /etc

Similar Posts: