Bash Ubuntu 16.04中混乱的路径环境变量

Bash Ubuntu 16.04中混乱的路径环境变量,bash,shell,ubuntu,terminal,path,Bash,Shell,Ubuntu,Terminal,Path,我试图安装Anaconda以一次获取多个python包,但python IDLE出现了一些问题,它说找不到包,因此必须在~/.bashrc中手动设置路径 一旦我在~/.bashrc中设置了路径,python IDLE中的导入错误就解决了,但我现在无法在终端上使用命令 我一直在犯这个错误 sid@sids-ubuntu:~$ ls Command 'ls' is available in '/bin/ls' The command could not be located because '/bi

我试图安装Anaconda以一次获取多个python包,但python IDLE出现了一些问题,它说
找不到包
,因此必须在
~/.bashrc
中手动设置路径

一旦我在
~/.bashrc
中设置了路径,python IDLE中的
导入错误
就解决了,但我现在无法在终端上使用命令

我一直在犯这个错误

sid@sids-ubuntu:~$ ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
sid@sids-ubuntu:~$ sudo
Command 'sudo' is available in '/usr/bin/sudo'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found
sid@sids-ubuntu:~$ mkdir aa
Command 'mkdir' is available in '/bin/mkdir'
The command could not be located because '/bin' is not included in the PATH environment variable.
mkdir: command not found
我做了
export PATH=/usr/bin:/bin
来查找我的
$PATH
/etc/environment
的内容。似乎两者都不一样

sid@sids-ubuntu:~$ export PATH=/usr/bin:/bin
sid@sids-ubuntu:~$ echo $PATH
/usr/bin:/bin
sid@sids-ubuntu:~$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
Ubuntu没有在
/etc/environment
中查找
$PATH
? 如果是,我的
$PATH
/etc/environment
不同的原因是什么?请帮我修好它!
如果没有,Ubuntu在哪里查找
$PATH
?请帮我修一下

路径添加一些目录时,最好不要覆盖以前的值,只需在
~/.bashrc
的末尾行添加所需的目录(例如
$HOME/bin
),并删除以前对
路径的任何篡改

并运行:

source ~/.bashrc

(或者只打开新的终端会话)。

请注意,您的/etc/环境只有在重新启动时才会被重新读取

如果要更改路径,请确保也包括现有零件。为此,请在新路径定义中添加$PATH

export PATH="$PATH:/usr/bin"
看看您的问题,在~/.bashrc中添加$PATH就可以了。如果没有,请打开一个新的终端,并向我们显示

echo $PATH

PATH是一个环境变量,因此不会在任何文件中查找它


调用bash时,有几个文件是源文件(请参阅bash手册页中名为INVOCATION的部分),在源文件时,可以分别设置环境变量PATH。请注意,
.bashrc
始终是未处理的;请仔细阅读bash手册页,以了解在何种条件下包含哪些文件。

我将
/etc/environment
的内容添加到
~/.bashrc
。。它现在可以正常工作了(我希望所有命令都能正常工作)…)
echo $PATH