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
來源:簡書
著作權歸作者所有。商業轉載請聯系作者獲得授權,非商業轉載請注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM