LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cannot execute bash: permission denied (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-execute-bash-permission-denied-471968/)

flipwhy 08-08-2006 09:46 AM

cannot execute bash: permission denied
 
hi...i get the above error when i try to login as root...which as you can imagine is really not very good!!
my .bash_profile is also not the same..it almost has nothing in it...about 3 lines..thats it.
ive chmod 755 for the .bash_profile and .bashrc files...and checked lib and bin and they r all ok... even the /bin/bash has 755 mode.
any ideas?

Agrouf 08-08-2006 10:00 AM

the $PATH is probably bad. Try setting it correctly in .bashrc

flipwhy 08-08-2006 11:10 AM

ok..i'm not sure exactly how to..
i checked PATH with echo...and it gave a long line of /sr/bin:/usr/sbin ...
within .bashrc..i dont know if there is a PATH..
could you gimme some more details.

anamericanjoe 08-08-2006 11:51 AM

As a normal user, try to determine where the binary is for bash with

Code:

which bash
That command will return the path to the version of bash that you use as a normal user.

Then, as root

Code:

echo $PATH
Check to see if this path includes the path to bash you found earlier. If it doesn't, your root's path is bad and you should add the path to your bash binary to your path.

nx5000 08-08-2006 12:03 PM

Quote:

Originally Posted by Agrouf
the $PATH is probably bad. Try setting it correctly in .bashrc

I think the path should be set in /etc/profile or maybe in .bash_profile but not in .bashrc.

(bashrc is not read on login shells)
Quote:

if [ "`id -u`" -eq 0 ]; then
PATH="/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"
fi

Agrouf 08-08-2006 12:05 PM

^
|

that is true.

flipwhy 08-08-2006 01:00 PM

i tried that..
when i put which bash...it said /bin/bash
so i added /bin: to the front of my PATH in the etc/profile file as well as the .bash_profile file.
Still not being allowed.

anamericanjoe 08-08-2006 01:14 PM

Have you checked the permissions on /bin/bash?

Try this:

Code:

ls -lag /bin/bash
Please post the result of this command.

flipwhy 08-08-2006 01:16 PM

ya...ive chmoded just about everything to 755

anamericanjoe 08-08-2006 01:57 PM

This may not fix your current problem, but you probably don't want a binary to be writable by anyone, not even root, since that allows the binary to become corrupt.

You'd probably be better off changing the permissions of /bin/bash to 555.

Also, what are the permissions on /bin, the directory?

Try

Code:

ls -ld /bin

flipwhy 08-08-2006 03:25 PM

yeah...theyre all executable by all and readable by all...
i think i just overly messed up..playing too much in root..
think ill just re-install.
thanks for you help. good stuff :)

cuco76 11-12-2007 10:49 AM

Had this same exact issue. Turns out the /etc dir was 700 so chmod to 755 and everything was fine.

Hope this helps someone out!

Chris


All times are GMT -5. The time now is 08:18 PM.