简体   繁体   中英

BASH and/or .BASHRC not working properly after SU or SSH login unless run "bash" command

I have an Amazon EC2 Machine running Ubuntu 10.04.

The default user, ubuntu's .bashrc seems to be behaving properly, but if I ssh or su to the second user, mikey, it doesn't display properly until I run bash :

Ex 1.) Changing user with su

mikey@home ~$ ssh ubuntu@EC2
ubuntu@EC2:~$
ubuntu@EC2:~$ su mikey
$ 
$ bash
mikey@EC2: $

Ex 2.) SSH-ing in directly as the user

mikey@home ~$ ssh mikey@EC2
/home/mikey/.bashrc: 13: shopt: not found
/home/mikey/.bashrc: 21: shopt: not found
/home/mikey/.bashrc: 99: shopt: not found
/etc/bash_completion: 33: [[: not found
/etc/bash_completion: 39: [[: not found
/etc/bash_completion: 52: Bad substitution
\[\e]0;\u@\h: \w\a\]\u@\h:\w$
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ bash
mikey@EC2:~$

I've tried playing around with ~/.profile and ~/.bash_login to include

if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

but so far, nothing has seemed to do the trick.

any pointers would be greatly appreciated. thanks!

If, in fact, your shell isn't bash , you can try to change it like so:

usermod -s /bin/bash mikey

If /bin/bash is the location of bash on that system.

I think your default shell is dash or sh and not bash in this case. echo $SHELL should show it, should it show /bin/sh , it might be a link, so check that ls -l /bin/sh doesn't link to some other shell.

Can't you use chsh to change shell? instead of hacking /etc/passwd?

In order to fix this on the permanent basis, change /etc/passwd

From:

kwilson:x:3042:3042::/home/jjson:/bin/sh

Change it to:

kwilson:x:3042:3042::/home/jjson:/bin/bash

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM