bash_completion 不起作用,未找到源命令
我最近继承了一个 Ubuntu Hardy 盒子,它的开箱即用功能相当时髦。我尝试做的第一件事是编辑我的 .bashrc 配置文件以进行一些着色并添加一些我通常拥有的别名,但是当我尝试获取 ~/.bashrc 时,我得到 sh: source: not found 而且我还注意到选项卡式自动完成功能也根本不起作用 - 我相信这称为 bash_completetion,但我相信你可以告诉我,我不是专家。
我是否应该编辑任何特定文件才能获得我习惯的开箱即用的基本功能?未安装 source 命令不是很不寻常吗?
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 found
and 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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一般思考过程:
使用
ps
确认您实际上使用的是sh
而不是bash
确认
/bin/bash
存在并正常工作(并且 [如果没有,请重新安装)使用
chsh
将您的登录 shell 更改为 bash安装 bash-completion 包(如果缺少)
General thought process:
Use
ps
to confirm you're actually usingsh
notbash
confirm that
/bin/bash
exists and works properly (and [re]install it if it doesn't)use
chsh
to change your login shell to bashinstall the bash-completion package if it's missing
您应该得到
bash: source: command not find
(当然,bash 永远不会找不到source
)。如果您得到sh:
,那么您要么根本没有运行 bash,要么运行带有告诉它假装是 Bourne shell/bin/sh
的标志的 bash 。输入 bash 来获得真正的 bash,或者编辑启动配置,这样它就不会为您传递该标志(不确定它们在 Ubuntu 中的位置)。You should be getting
bash: source: command not found
(except that bash will never fail to findsource
, of course). If you getsh:
, 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
. Typebash
to 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).Ubuntu 服务器有时将 /bin/sh 作为默认 shell。这与您发布的问题一致,因为 /bin/sh 没有可用的 source 命令。如果您发现缺少 bash 功能,则可能您没有使用 bash。以下是要遵循的步骤,以及每次登录新的 *nix 盒子时要记住的一些内容:
echo $0
检查您正在使用的 shellcat /etc 可以使用哪些 shell /贝壳
/bin/bash
apt-get install bash
(特定于 Ubuntu/Debian)exec /bin/bash
开始使用 bash 使用chsh -s /bin/bash
将 bash 设置为登录 shellUbuntu 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:
echo $0
cat /etc/shells
/bin/bash
in the list if you want to use bashapt-get install bash
(Ubuntu/Debian specific)exec /bin/bash
chsh -s /bin/bash