[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
[[email protected] ~]# 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
[[email protected] ~]# ls -ld /home/mongodb/
drwx—— 2 504 504 4096 Jul 15 13:50 /home/mongodb/

3: Solution
Modify the owner,modify the permissions
[[email protected] ~]# chown -R mongodb:mongodb /home/mongodb/
[[email protected] ~]# chmod -R 755 /home/mongodb/
[[email protected] ~]# su – mongodb
[[email protected] ~]$
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: