LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   cannot execute /bin/bash: Permission Denied (https://www.linuxquestions.org/questions/linux-from-scratch-13/cannot-execute-bin-bash-permission-denied-33216/)

peeples 10-19-2002 08:54 AM

cannot execute /bin/bash: Permission Denied
 
I'm probably gonna feel like a real noob when someone tells me how to fix this, but, here goes...

I've had LFS up and running for a week now. Been snooping around and looking at how the system is set up. Decided to actually start using it, so I figured I'd better set up a user account. Well, after I got it set up, Tried to login with it. Got the "cannot execute /bin/sh: Permission Denied" thing. Well I checked permissions on both the /bin/sh link (777) and /bin/bash (755). So I said to myself, why is it using sh? Looked in the passwd file, found that and changed it to /bin/bash. Checked for a /home/peeples directory, it wasn't there, so I added it via root account and chown peeples: peeples. Since it was a new directory it was empty, so I copied .bash* from my base distro into this new directory. Tried to login with user again, got "cannot execute /bin/bash: Permission Denied". Since it changed from /bin/sh to bin/bash, I now know that it's reading the passwd file correctly. I double-checked ownership of my home directory, everything is correct. When I looked in /bin everything is root:root, all links are 777, and all other files are 755, that's right, isn't it? How can I get my user account running?

TIA

lfslinux 10-19-2002 10:06 AM

Check the permissions on the / directory. If it's not set to something like 755 the normal users aren't able to get to their home directories or any other directories, no matter if /bin itself has proper permissions. / is the first directory accessed and it needs to be 755 too.

So run ls -ld / and see what it reports and fix accordingly if something is out of the ordinary.

peeples 10-19-2002 02:23 PM

Permissions on / are correct at 755. Anything else to check?

lfslinux 10-19-2002 02:50 PM

How about the /home directory itself?

peeples 10-19-2002 07:33 PM

/home is owned by root:root (755). What next?

BTW, the permissions and ownership don't change, right? Because instead of rebooting into my LFS to check this stuff, I've just mounted the partition under /lfs in my base distro. Then I just cd to the parent directory and type ls -la. If I have to reboot it's no problem, I just don't want to waste your time if I'm giving you wrong answers...

Thanks.

lfslinux 10-19-2002 07:54 PM

It might be a factor, depending on how your partitions are mounted according to the $LFS/etc/fstab file

Best is to actually boot into LFS and give the outputs of these commands:

ls -ld / /home /home/youruser

It should give output similar to this:

gerard@lorien:~$ ls -ld / /home /home/gerard
drwxr-xr-x 16 root root 360 Oct 15 12:36 /
drwxr-xr-x 9 root root 192 Oct 16 15:03 /home
drwxr-x--- 55 gerard gerard 4016 Oct 19 18:19 /home/gerard

peeples 10-19-2002 09:16 PM

Ok, I booted into lfs. Logged in as root. then typed:

ls -ld / /home /home/peeples > test

This is what was in the test file:

drwxr-xr-x 19 root root 4096 Oct 19 14:45 /
drwxr-xr-x 3 root root 4096 Oct 19 08:12 /home
drwxr-xr-x 2 peeples peeples 4096 Oct 19 14:49 /home/peeples

lfslinux 10-19-2002 09:53 PM

Uhmmm /me scratches his head
Why are we checking the /home/peeples directory again when the error shows /bin/bash Permission Denied

Run this ls -ld /bin

Does it have a mode of 755 too?

peeples 10-20-2002 09:43 AM

Booted back into LFS.

ls -ld /bin gives root:root at 755

Went into /etc/passwd again. This is its contents:

root:U/7pZokqZN8v6:0:0:root:/root:/bin/bash
peeples:Dn8YWXGhsP/2o:506:506:peeples:/home/peeples:/bin/bash

(except change the smilies back to their text equivilents)


Also looked in /etc/group. This is its contents:

root:x:0:
bin:x:1:
sys:x:2:
kmem:x:3:
tty:x:4:
tape:x:5:
daemon:x:6:
floppy:x:7:
disk:x:8:
lp:x:9:
dialout:x:10:
audio:x:11:
peeples:x:506:


What next?

peeples 10-21-2002 08:20 PM

Still having this problem. Cannot find answers on IRC. Please help...

lfslinux 10-21-2002 08:49 PM

Boot LFS run "/bin/mount" and show the line that represents your root partition.

peeples 10-22-2002 05:41 PM

The results of /bin/mount are as follows:

rootfs on / type rootfs (rw)
/dev/root on / type ext2 (rw)
proc on /proc type proc (rw)
/dev/hda2 on /redhat type ext3 (rw)

denny

lfslinux 10-22-2002 06:19 PM

I admit, I've no idea. The mount options are right and the permission on all paths involved are right too.

Can you login as root?

If so, login as root, then sun this: "su - peeples"

make sure you type that - as it means that the session will be a login session.

Do you get errors?

peeples 10-22-2002 07:17 PM

Rebooted to LFS. Logged in as root. Typed "su - peeples" and got:

No mail.
cannot execute /bin/bash: Permission Denied

and it kicked me back to login: prompt. I logged back in as root, added a new user peeps, made a password for that account, and made a home directory owned by peeps at 755. Tried logging in with that account and recieved:

Last login at blah, blah, blah
No mail.
cannot execute /bin/bash: Permission Denied

That was on the first login with peeps account. I don't know where it came up with a prior login time.

So, the only account that works is root.

Denny

MasterC 10-23-2002 01:46 PM

Have you tried changing your entry in /etc/passwd for any given user from /bin/bash to /bin/sh just to see if you get another response, or any other shell?

Just trying to toss out suggestions as well

Cool

peeples 10-23-2002 05:31 PM

Yeah, In fact, that's what I was getting when this started: "cannot execute /bin/sh: Permission Denied" (see first post). Then I changed the entry in passwd to /bin/bash, same result.

But I appreciate all suggestions.

Anyone else? I would hate to have to bomb the partition and start all over (sigh)..

adam_boz 10-23-2002 10:31 PM

just a thought....

try doing "file /bin/bash" and see what that gives you. this is what I got:

bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0, dynamically linked (uses shared libs), not stripped

I'm thinking that maybe you installed it wrong.

what does your /etc/fstab look like?

EDIT:

I just read through again... I didn't realize that it works o.k. for root.... you probably installed it fine.

just for kicks.... try doing "chown peebles /bin/bash"

moses 10-24-2002 01:18 AM

Try:

chown root:bin /bin

peeples 10-24-2002 07:46 AM

Adam: I'm at work right now. Will post fstab when I get home.

Moses: Correct me if I'm wrong here. If I change to "chown root:bin /bin" then the group of the directory bin will be the group bin. If I'm not a member of either root group or bin group, then I'm relying on the last 5 in the 755 permissions to be able to use the file, so changing the group shouldn't have any effect. But, I'm sure gonna try it because I'm getting desperate.

Oh, shit. I just thought of something. When I went into the passwd file to change from /bin/sh to /bin/bash, I noticed the UID of the account was 1000. I don't know why, but I thought it might be nice to have all the UID numbers for user accounts in LFS to match what they were in RedHat. So I changed the UID to 506. If there is another file that does the translation from UID to english, then THAT might be the problem! I wish I was at home so I could try changing it back to 1000. How about it Gerard, Adam, Moses, and MasterC? Could that be it? Let me know

moses 10-24-2002 12:37 PM

Yeah, sorry. It was late and I didn't fully read (thought I had) your posts.

Ideas:

The UID probably isn't the problem, since /etc/passwd is the only place
this is set.

This is probably secondary, but are you using vipw to edit your passwd
file (vigr to edit group, vipw -s to edit the shadow password file)? This
command checks whether the file is correct when you quit.

I see that you have this from mount:

rootfs on / type rootfs (rw)
/dev/root on / type ext2

What kernel are you running? The rootfs is 2.5.x stuff (development,
not released in 2.4.x). This could very well be the culprit.

How did you add your new users? LFS suggests the use of useradd,
I don't see why just doing it yourself would cause a problem (it never
has for me), but. . .

peeples 10-24-2002 02:10 PM

Moses:

Nah, I just type

vi passwd

to edit the passwd file.


I'm pretty sure that the kernel is 2.4.19 (about 98% sure).

I used useradd to add a user.


denny

peeples 10-24-2002 05:34 PM

PROBLEM SOLVED!!!

I booted into LFS, logged in as root. cd'd to / and did a ls -la

I remembered the book saying that all directories should be 755 by default, and then we changed two of them so diffeent values. Well, /dev, /mnt, /proc, and /opt weren't at 755. Once I did a chmod 755 on them, I was able to login as username.

One tiny problem, now that I'm able to login as peeples:

When I did a directory listing on /home/peeples instead of showing the owner and group name it shows the UID & GID . I logged out, logged back in as root, and it doesn't do that in the root account. What's up with that?

Thanks so much for your help guys!

denny

adam_boz 10-24-2002 07:03 PM

I can only think of /proc doing something funny.... I think that was probably the source of your troubles ( better chance it was that than /mnt or /opt ).

I don't know... congradulations on getting your user access to bash though.

MasterC 10-24-2002 08:16 PM

Wow, I was really feeling bad for you, assuming you missed some vital step way back in part 1 of ch 5. Glad you got it fixed, and I agree with adam, I can't see anything in /mnt or /opt or even really /dev that would do something like that to you.

Glad you got it working.

Cool

ccool 10-25-2002 08:07 AM

If you see te UID and the GID instead of your group name and user name as the owner of your /home/peeples directory, it is because you changed your UID and GID in /etc/group and /etc/passwd...

anyway, you can make everything work fine with the chown and chgrp command (just set it with the right names)


All times are GMT -5. The time now is 09:08 AM.