修改环境变量引起的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
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
C 在计算机领域中,修改环境变量是指更改操作系统或某个应用程序的环境配置参数。环境变量包含了一些系统或应用程序运行所需的重要参数信息,如系统路径、临时文件目录等。修改环境变量能够影响程序的运行行为和功能。 一般来说,要修改环境变量需要进入操作系统的设置界面。在Windows操作系统中,可以通过以下步骤进行修改: 1. 打开"控制面板"。 2. 选择"系统和安全"或"系统",然后点击"系统"。 3. 在系统设置页面中,点击"高级系统设置"。 4. 在弹出的"系统属性"窗口中,选择"高级"选项卡,点击"环境变量"按钮。 5. 在"用户变量"或"系统变量"部分中,选择需要修改环境变量,点击"编辑"或"新建"按钮。 6. 在弹出的编辑窗口中,可以修改变量名和变量值。完成修改后,点击"确定"关闭窗口。 在Linux和Unix操作系统中,可以通过编辑配置文件来修改环境变量。常见的环境变量配置文件有`/etc/environment`、`~/.bashrc`和`~/.bash_profile`等。在终端中使用编辑器打开相应的文件,找到需要修改环境变量所在行,进行修改并保存文件。 需要注意的是,修改环境变量可能会对系统和应用程序产生影响,请谨慎操作。确保只修改自己熟悉的环境变量,并备份相关配置文件,以免出现错误。如果修改后出现问题,可以恢复为原始配置或咨询相关技术支持人员的帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值