Pages

Unixbhaskar's Blog

Wednesday, July 11, 2012

How to fix shell "permission denied" error

I believe everyone,who works on terminal for certain length of time come across this error sometime.

Very trivial topic so the fixing is also very trivial too.

Once you tried to logged into the shell you get the "permission denied" error on the console but get the shell prompt and most importantly you can not do a "ls" and other stuff too.

But you can login to the shell as root fine..without any error..it's the normal user that is getting it!!

So it signifies, something wrong with the way disk has been mounted.But once you give the correct flags with the mount it will work..but once you reboot it will started to react in same manner i.e erroneously.

How to do it right?

simple, put an entry like this in /etc/rc.local(that is file executed last at boot stage)

chown -R username:groupname disk-partition

I have had multiple disk partitions and I did that.

and make /etc/rc.local file executable by doing a chmod. Additionally check for /etc/nologin file..if that is present..then it might hinder you to get in.Double check the shell you are trying to use is exists.

That's all you need to do..next reboot it should be good.

Tip: Be careful about /dev/null! if the permission of this file get changed ;you might get the "permission denied" error too on console.So,you need to fixed that by running "mknod" to recreate it and assign the correct permission to this file.Normally it should look like this:

ls -al /dev/null
crw-rw-rw- 1 root root 1, 3 Jul 11 08:34 /dev/null


Udev plays a role to determine the right thing about those.So keep an eye on Udev related matters on system.


Hope this will help.

Cheers!
Bhaskar