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

来自: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功能恢复。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值