除非运行“bash",否则在 SU 或 SSH 登录后 BASH 和/或 .BASHRC 无法正常工作命令 [英] BASH and/or .BASHRC not working properly after SU or SSH login unless run "bash" command

查看:24
本文介绍了除非运行“bash",否则在 SU 或 SSH 登录后 BASH 和/或 .BASHRC 无法正常工作命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行 Ubuntu 10.04 的 Amazon EC2 机器.

I have an Amazon EC2 Machine running Ubuntu 10.04.

默认用户,ubuntu 的 .bashrc 似乎行为正常,但是如果我 sshsu 到第二个用户 mikey,在我运行 bash 之前它不能正确显示:

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.) 使用 su

Ex 1.) Changing user with su

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

Ex 2.) 直接以用户身份登录

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: wa]u@h:w$
[e]0;u@h: wa]u@h:w$ bash
mikey@EC2:~$

我尝试使用 ~/.profile~/.bash_login 来包含

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!

推荐答案

如果实际上你的 shell 不是 bash,你可以尝试像这样改变它:

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

usermod -s /bin/bash mikey

如果/bin/bash 是 bash 在该系统上的位置.

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

这篇关于除非运行“bash",否则在 SU 或 SSH 登录后 BASH 和/或 .BASHRC 无法正常工作命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆