ubuntu 登录不上/ 环境变量失效 The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.

机器上编译了5.0/6.0的源码,安装的jdk1.7 ,然后由于需要编译4.2.2,所以又安装了jdk1.6 ,配置了环境变量

gedit /etc/environment 改成如下

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games”

PATH=”$PATH:/usr/lib/jvm/jdk1.6.0_43/bin:/usr/lib/jvm/jdk1.6.0_43″

JAVAHOME=”/usr/lib/jvm/jdk1.6.0_43″

CLASSPATH=”$JAVAHOME/lib:$JAVAHOME/jre/lib”

JRE_HOME=$JAVA_HOME/jre

编译源码成功后,第二天重启,发现图形登录界面密码正确登录不上,循环跳回登录界面.

Ctrl+ Alt+ F1 进入tty1 ,输入用户名和密码,但是基本命令都用不了,如reboot/ls/rm/nano/vi都不行,提示

The command could not be located because ‘/usr/bin:/bin’ is not included in the PATH environment variable.

后来在网上搜索到  http://blog.163.com/shao_yuru/blog/static/130517606201010310581842/

删掉/etc/environment添加的部分,修改前记得备份,重启正常.

本质原因是 /etc/environment PATH第一个是系统的命令路径,第二个把PATH再赋值给覆盖了导致系统找不到命令.

http://www.oschina.net/question/1762880_233348也是同样问题

gedit ~/.bashrc 里修改  source ~/.bashrc生效

以下是我个人的看法,一般而言,在Linux中,我不喜欢修改/etc/profile里的内容,那里相当于系统环境变量,一般我们只需更改自己用

户的环境变量配置文件(.bashrc)即可,这样可以保证多个用户的独立性。当然了,对于Eclipse(或者说对于Java)这个工具,你要是觉得所

有用户都应该使用,修改/etc/profile也有一定道理。

不过,如果你是像我这种将jdk和eclipse都放在自己家目录的话,修改.bashrc还是比较有道理的吧,因为.bashrc才是属于自己的东西。

gedit ~/.bashrc 配置如下

#add for jdk1.6

export JAVAHOME=”/usr/lib/jvm/jdk1.6.0_43″

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

export PATH=${PATH}:/root/Tools/sdk/tools

export PATH=${PATH}:/root/Tools/sdk/platform-tools

#add for 4418 gcc

export PATH=/opt/FriendlyARM/toolchain/4.9.3/bin:$PATH

export GCC_COLORS=auto

#add for NDK

export NDK=/opt/ndk/android-ndk-r10c

export PATH=$NDK:$PATH

# ~/.bashrc: executed by bash(1) for non-login shells.

# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)

# for examples

# If not running interactively, don’t do anything

[ -z “$PS1” ] && return

# don’t put duplicate lines in the history. See bash(1) for more options

# … or force ignoredups and ignorespace

HISTCONTROL=ignoredups:ignorespace

# append to the history file, don’t overwrite it

shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)

HISTSIZE=1000

HISTFILESIZE=2000

# check the window size after each command and, if necessary,

# update the values of LINES and COLUMNS.

shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)

[ -x /usr/bin/lesspipe ] && eval “$(SHELL=/bin/sh lesspipe)”

# set variable identifying the chroot you work in (used in the prompt below)

if [ -z “$debian_chroot” ] && [ -r /etc/debian_chroot ]; then

debian_chroot=$(cat /etc/debian_chroot)

fi

# set a fancy prompt (non-color, unless we know we “want” color)

case “$TERM” in

xterm-color) color_prompt=yes;;

esac

# uncomment for a colored prompt, if the terminal has the capability; turned

# off by default to not distract the user: the focus in a terminal window

# should be on the output of commands, not on the prompt

#force_color_prompt=yes

if [ -n “$force_color_prompt” ]; then

if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then

# We have color support; assume it’s compliant with Ecma-48

# (ISO/IEC-6429). (Lack of such support is extremely rare, and such

# a case would tend to support setf rather than setaf.)

color_prompt=yes

else

color_prompt=

fi

fi

if [ “$color_prompt” = yes ]; then

PS1=’${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘

else

PS1=’${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ‘

fi

unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir

case “$TERM” in

xterm*|rxvt*)

PS1=”\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1″

;;

*)

;;

esac

# enable color support of ls and also add handy aliases

if [ -x /usr/bin/dircolors ]; then

test -r ~/.dircolors && eval “$(dircolors -b ~/.dircolors)” || eval “$(dircolors -b)”

alias ls=’ls –color=auto’

#alias dir=’dir –color=auto’

#alias vdir=’vdir –color=auto’

alias grep=’grep –color=auto’

alias fgrep=’fgrep –color=auto’

alias egrep=’egrep –color=auto’

fi

# some more ls aliases

alias ll=’ls -alF’

alias la=’ls -A’

alias l=’ls -CF’

# Alias definitions.

# You may want to put all your additions into a separate file like

# ~/.bash_aliases, instead of adding them here directly.

# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then

. ~/.bash_aliases

fi

# enable programmable completion features (you don’t need to enable

# this, if it’s already enabled in /etc/bash.bashrc and /etc/profile

# sources /etc/bash.bashrc).

#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then

#    . /etc/bash_completion

#fi

    原文作者:水木井
    原文地址: https://www.jianshu.com/p/44ec005546fe
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞