小编KGo*_*ang的帖子

BASH_VERSION 未设置且 .bashrc 未在交互式 shell 中获取

我通过执行创建了一个新用户

sudo useradd -m harry

当我尝试用“su - harry”替换用户时,我能看到的一切都是“$”(美元)符号,自动完成功能不起作用,并且 shell 内置函数(例如源代码)不可用。

我检查了 .bashrc 和 .profile 并检测到 .bashrc 没有被获取,因为 $BASH_VERSION 没有设置。

.profile 中的代码如下所示:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi
Run Code Online (Sandbox Code Playgroud)

该命令不echo $BASH_VERSION返回任何内容。

$ echo $BASH_VERSION

$ 
Run Code Online (Sandbox Code Playgroud)

Shell 内置函数(源 .bashrc、. .bashrc)也不起作用。

SHELL 变量值是“/bin/sh”,它是破折号的别名。我将其更改为 /bin/bash(导出 SHELL=/bin/bash)但它没有任何效果。

当我在 .profile 中硬编码“. .bashrc”(当然,只是为了检查它是否有效)我收到几个错误:

admin@host:~$ sudo su - harry
-su: 13: /home/harry/.bashrc: shopt: not found
-su: 21: …
Run Code Online (Sandbox Code Playgroud)

source 12.04

4
推荐指数
1
解决办法
3653
查看次数

标签 统计

12.04 ×1

source ×1