Wednesday, April 10, 2013

"su: No directory!" and "su: No shell" error

Problem:

You can log in as root, but when you try to switch to other user by running "su - username", you get "su: No directory!" error.

example:

command ran:

su - testuser

error:

su: No directory!

You also get "su: No shell" error when you try to run a command as a user by running " su username -c 'echo test' "

example:

su testuser -c 'echo test'

error:

su: No shell

Solution:

The permission on / is set up incorrectly. you probably have drwx for /. Other user need to have execute permission on / in order to solve this problem.

you can fix this by running this command:

chmod o+x /



Old permission:

 # ls -la /

drwx------  19 root     root          22 Sep 28  2009 .
drwx------  19 root     root          22 Sep 28  2009 ..

New permission:

# ls -la /

drwx-----x  19 root     root          22 Sep 28  2009 .
drwx-----x  19 root     root          22 Sep 28  2009 ..