如何解决“无法找到命令,因为 '/bin:/usr/bin' 未包含在 PATH 环境变量中”错误?

JB.*_*mar 2 permissions command-line bash directory environment-variables

我已经安装了 Ubuntu 20.04.3 LTS 并安装了 Anaconda3,但由于出现一些问题,我不得不卸载 Anaconda3。我以 root 身份使用此命令从/home/user目录中删除了它:

# rm -f anaconda3
Run Code Online (Sandbox Code Playgroud)

之后我遇到了以下问题:

$ sudo -s
# ls
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found
Run Code Online (Sandbox Code Playgroud)

这是我的最后几行.bashrc

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/thilipkumar/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/thilipkumar/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
Run Code Online (Sandbox Code Playgroud)

以下是echo path普通用户和 root 的输出:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/thilipkumar/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/thilipkumar/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
Run Code Online (Sandbox Code Playgroud)

谁能建议我下一步该做什么?

van*_*ium 5

检查root用户的/root/.profile/root/.bashrc文件以更正路径设置错误的位置。

您还可以通过将相应文件复制/etc/skel/root.