以前,当我在终端中错误地输入了一个错误的命令时,我会得到这样的输出:
Command 'whoaim' not found, did you mean:
command 'whoami' from deb coreutils (8.30-3ubuntu2)
Try: sudo apt install <deb name>
但现在当我输入错误的命令,如whoaim
而不是whoami
,我得到这样的输出:
bash: whoaim: command not found
我应该如何重置bash配置?
可以使用以下命令重置用户的bash配置文件:-
覆盖用户主目录下已有的.bashrc
cp /etc/skel/.bashrc ~/
source ~/.bashrc
备份已有的.bashrc从用户的主目录
但是,在这里查看如何在ubuntu
中使用command-not-found
实用程序您需要调用一个为bash提供此功能的函数。通常称为command_not_found_handle
。首先,将其附加到.bashrc
文件中。下面是代码:
command_not_found_handle ()
{
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1";
return $?;
else
if [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1";
return $?;
else
printf "%s: command not foundn" "$1" 1>&2;
return 127;
fi;
fi
}
然后运行以下命令重新加载配置文件:
. ~/.bashrc