bash bash_completion 不起作用,找不到源命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2455787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bash_completion not working, source command not found
提问by kylemac
I recently inherited a Ubuntu Hardy box that acts rather funky out-of-the-box. The first things I tried to do was edit my .bashrc profile to do some coloring and add some aliases I usually have, but then when I try to source the ~/.bashrc I get sh: source: not foundand I have also noticed tabbed autocomplete is also not working at all - I believe this is called bash_completetion, but as I'm sure you can tell, I'm not an expert.
我最近继承了一个 Ubuntu Hardy 盒子,它开箱即用。我尝试做的第一件事是编辑我的 .bashrc 配置文件以进行一些着色并添加一些我通常拥有的别名,但是当我尝试获取 ~/.bashrc 的源时sh: source: not found,我也注意到选项卡式自动完成功能也不起作用完全 - 我相信这被称为 bash_completetion,但我相信你可以说,我不是专家。
Are there any specific files I should be editing to get this basic functionality I am accustomed to out-of-the-box? and isn't it unusual for the source command to not be installed?
是否有我应该编辑的特定文件以获得我习惯于开箱即用的基本功能?不安装 source 命令是不是很不寻常?
回答by Cascabel
General thought process:
一般的思考过程:
Use
psto confirm you're actually usingshnotbashconfirm that
/bin/bashexists and works properly (and [re]install it if it doesn't)use
chshto change your login shell to bashinstall the bash-completion package if it's missing
使用
ps你实际使用确认sh不bash确认
/bin/bash存在并正常工作(如果没有,请[重新]安装)用于
chsh将您的登录 shell 更改为 bash如果缺少 bash-completion 软件包,请安装它
回答by Kilian Foth
You should be getting bash: source: command not found(except that bash will never fail to find source, of course). If you get sh:, then you're either not running bash at all, or running bash with the flag that tells it to pretend it's the Bourne shell /bin/sh. Type bashto get a real bash, or edit the startup configuration so that it doesn't pass that flag for you (not sure where they are in Ubuntu).
你应该得到bash: source: command not found(source当然,bash 永远不会找不到)。如果你得到sh:,那么你要么根本不运行 bash ,要么运行 bash 并带有告诉它假装它是 Bourne shell 的标志/bin/sh。输入bash以获得真正的 bash,或编辑启动配置,以便它不会为您传递该标志(不确定它们在 Ubuntu 中的位置)。
回答by spex
Ubuntu servers sometimes have /bin/sh as the default shell. This is consistent with the issue you posted, as /bin/sh does not have the source command available. If you are noticing missing bash features, it might be possible that you aren't in bash. Here are the steps to follow, and something to remember whenever you log on to a new *nix box:
Ubuntu 服务器有时将 /bin/sh 作为默认 shell。这与您发布的问题一致,因为 /bin/sh 没有可用的 source 命令。如果您注意到缺少 bash 功能,则您可能不在 bash 中。以下是要遵循的步骤,以及每次登录新的 *nix 框时要记住的内容:
- Check which shell you are using with
echo $0 - See what shells are available with
cat /etc/shells- Look for
/bin/bashin the list if you want to use bash - If bash is not in the list,
apt-get install bash(Ubuntu/Debian specific)
- Look for
- Start using bash with
exec /bin/bash - Set bash as your login shell with
chsh -s /bin/bash
- 检查您正在使用哪个外壳
echo $0 - 看看有哪些 shell 可用
cat /etc/shells/bin/bash如果要使用 bash,请在列表中查找- 如果 bash 不在列表中,
apt-get install bash(特定于Ubuntu/Debian)
- 开始使用 bash
exec /bin/bash - 将 bash 设置为您的登录 shell
chsh -s /bin/bash

