修改环境变量引起的bash 出错 解决方案

来源:互联网 发布:淘宝铠甲勇士烈焰刀 编辑:程序博客网 时间:2024/04/29 11:36

来自:http://www.iteye.com/wiki/blog/1244124

打开ubuntu 发现了 bash 的出错信息,如下,上网检索了一下 发现是环境变量有错误,找了多种方法 下面的方法是有效的一种。


错误信息

Command 'lesspipe' is available in the following places

 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
Command 'uname' is available in '/bin/uname'
The command could not be located because '/bin' is not included in the PATH environment variable.
uname: command not found
bash: [: !=: unary operator expected
bash: [: too many arguments
bash: [: too many arguments
bash: [: too many arguments
bash: [: =: unary operator expected
bash: [: too many arguments
bash: [: too many arguments
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: =: unary operator expected
Command 'sed' is available in '/bin/sed'
The command could not be located because '/bin' is not included in the PATH environment variable.
sed: command not found
bash: [: too many arguments

bash: [: =: unary operator expected
bash: [: too many arguments
bash: [: too many arguments
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: =: unary operator expected
ema@ubuntu:~$ sudo vi /usr/bin/vi ~/.bashrc
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
ema@ubuntu:~$ LS
The program 'LS' is currently not installed.  You can install it by typing:
sudo apt-get install sl
ema@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
ema@ubuntu:~$ sudo vi /usr/bin/vi ~/.bashrc
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
ema@ubuntu:~$ echo $PATH
/opt/program/mx53_smd/out/host/linux-x86/binPATH
ema@ubuntu:~$ export PATH=/usr/bin/:$PATH
ema@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
ema@ubuntu:~$ sudo gedit /root/.bash_profile
[sudo] password for ema: 
ema@ubuntu:~$ su -root
Command 'su' is available in '/bin/su'
The command could not be located because '/bin' is not included in the PATH environment variable.
su: command not found
ema@ubuntu:~$ sudo su
Command 'lesspipe' is available in the following places
 * /bin/lesspipe
 * /usr/bin/lesspipe
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
root@ubuntu:/home/ema# echo $PATH
/usr/local/arm/arm-2009q1/bin:/opt/program/mx53_smd/out/host/linux-x86/binPATH
root@ubuntu:/home/ema# env
Command 'env' is available in '/usr/bin/env'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
env: command not found
root@ubuntu:/home/ema# gedit /root/.bashrc
Command 'gedit' is available in '/usr/bin/gedit'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
gedit: command not found
root@ubuntu:/home/ema# pwd
/home/ema
root@ubuntu:/home/ema# cd /
root@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

root@ubuntu:/# pwd


解决方案切换到root 然后执行以下命令

root@ubuntu:/# /usr/bin/sudo -i
root@ubuntu:~# /usr/bin/nano /etc/bash.bashrc
把bashrc文件中添加的错误信息 去掉

比如我的bashrc文件中

最后一行 export PATH=/opt/program/mx53_smd/out/host/linux-x86/binPATH

把此行去掉bash功能恢复。

0 0
原创粉丝点击