ubuntu的ubuntu设置环境变量量有什么用

ubuntu 环境变量改错导致所有命令用不了 - qq_的博客 - CSDN博客
ubuntu 环境变量改错导致所有命令用不了
当你很嗨皮的copy网上的内容修改环境之后,突然之间linux很多命令都用不了,均提示没有此命令。这下你傻眼了,什么命令都用不了了,这就是系统环境变量出现了问题导致所有的命令都找不到了,因为Linux的命令都是在/usr/bin/下。出现这种可能性的原因有很多,大多数是因为,安装了新的软件要配置环境变量,但是没有按照正常程序来走。
例如:path= /etc/java/apache-**,这样就会吧原来path的所有可执行的程序都给干掉了,正确配置应该是path= $PATH:/etc/java/apache-**,在你要添加新的环境变量前要把所有的变量都写上,否则会造成你新设置变量,替换了以前的,$PATH是简写。
解决办法:
先用:echo $PATH&&
查看path是否含有:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin,如果没有,先用临时环境变量(重启后消失)
#export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
然后就可以用那些命令了,进去修改永久环境变量:
1。修改profile文件:(所有用户)
#vi /etc/profile
加入:export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
保存退出。
2。修改.bashrc文件:(单独用户)
#vi /~/.bashrc (‘~’代表:$HOME,& .bashrc是每个用户家目录下都有的,ls -all)
加入:export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
保存退出。
重启系统,搞定。
也可以不用重启,使用命令:#source .bashrc&
即可使刚刚修改的环境变量生效
相关文章推荐Ubuntu下android adb环境变量配置方法
投稿:junjie
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了Ubuntu下android adb环境变量配置方法,本文给出了操作步骤,按步骤操作即可,需要的朋友可以参考下
系统:linux ubuntu12
1. 配置环境变量
sudo gedit /etc/profile
在文件的最后追加一下内容(your_android-sdk-linux_path是绝对路径):
#set path for android sdk tools
export PATH=$PATH:/your_android-sdk-linux_path/tools/
export PATH=$PATH:/your_android-sdk-linux_path/platform-tools/
#set path for android sdk tools
export PATH=$PATH:/home/zhangle/software/android-sdk-linux/tools/
export PATH=$PATH:/home/zhangle/software/android-sdk-linux/platform-tools/
2、保存后,同步更新
source /etc/profile
3.输入adb 看是否安装成功。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具ubuntu的环境变量有什么用_百度知道
ubuntu的环境变量有什么用
我有更好的答案
所谓的环境变量是对于命令的作用。例如你在某个目录安装这个命令,你退出这个目录这个命令就没法用了。那么你就可以设置环境变量,无论你鼠标箭头在哪里都可以用这个命令。
采纳率:44%
来自团队:
为您推荐:
其他类似问题
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。设置Ubuntu环境变量 PATH 的方法 及配置备份
在Ubuntu中有如下几个文件可以设置环境变量 /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. /etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量 ~/.
在Ubuntu中有如下几个文件可以设置环境变量 /etc/profile:在登录时,操作系统定制用户环境时使用的第一个文件,此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. /etc/environment:在登录时操作系统使用的第二个文件,系统在读取你自己的profile前,设置环境文件的环境变量 ~/.profile:在登录时用到的第三个文件是.profile文件,每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件. /etc/bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取. ~/.bashrc:该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该该文件被读取. 通常设置环境变量有三种方法: 一、临时设置 export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH 二、当前用户的全局设置 打开~/.bashrc,添加行: export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH 使生效 source .bashrc 三、所有用户的全局设置 $ vim /etc/profile 在里面加入: export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH 使生效 source profile 测试 echo $PATH 有两种设置环境变量 PATH 的方法。第一种适用于为单一用户设置 PATH,第二种是为全局设置 PATH。 1.在用户主目录下有一个 .bashrc 文件,可以在此文件中加入 PATH 的设置如下: 用gedit /root/.bashrc打开 export PATH=”$PATH:/your path1/:/your path2/…..” 注意:每一个 path 之间要用 “:“ 分隔。 2.在/etc/profile中增加。 PATH="$PATH:/home/zhengb66/bin" export PATH 如果要使得即时生效,使用 source 命令 source .bashrc 完成。 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@【以上转自】http://blog.mcuol.com/User/For_ATIW/Article/11709_1.htm,另以下所介绍的方法只在一个终端中生效,另外打开新的终端发现PATH还是原来的PATH。要永久改变PATH 参见本文末的介绍~ PS1:直接修改文件内容的方法没有尝试过——针对方法1,因为在虚拟机下安装的,没有root权限修改/root下的文件; 针对方法2,在Ubuntu中找到的/etc/profile写得很诡异,看不懂,没找到类似“PATH=***”的内容。 PS2:自己琢磨成功——在终端中用命令的形式修改: ~$ echo $PATH
# 显示当前环境变量 /usr/local/sbin:/usr/local/bin
# 显示举例,多个路径中间用“:”隔开 ~$ PATH="$PATH:/home/workdir"
# 添加“/home/workdir”目录 /usr/local/sbin:/usr/local/bin:/home/workdir
# 显示举例,多个路径中间仍用“:”隔开 则添加成功!(最后当然可以重启或者输出使其即时生效:) ~$ export PATH ~$ cd ~ ~$ source .bashrc
#该命令需在主目录下才能运行,否则提示找不到.bashrc命令 结束! PS3:写命令的时候严格按此形式,在“=”前后千万不要有空格,否则提示“bash: PATH: command not found”错误。笔者曾吃过这样的狠亏,主要严格遵照上边的方法就可以解决问题了。 【永久性改变PATH的方法】 参考http://hi.baidu.com/youjim/blog/item/da912cd012fad.html 打开~/.bashrc文件最末添加命令: PATH=$PATH:/home/workdir 注意与上文中各式不同,没有双引号,重启解决。 为了您的安全,请只打开来源可靠的网址 打开网站
取消 来自: http://hi.baidu.com/%D6%AA%D3%EA%CF%FE%C7%E7/blog/item/9.html roo@ubuntu:~$ cat /etc/profile # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*. do
if [ -r $i ]; then
unset i fi if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc
if [ "`id -u`" -eq 0 ]; then
fi fi umask 022 roo@ubuntu:~$ roo@ubuntu:~$ cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:" roo@ubuntu:~$ roo@ubuntu:~$ cd ~ roo@ubuntu:~$ cat /.profile cat: /.profile: 没有那个文件或目录 roo@ubuntu:~$ cat .profile # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/ for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc"
fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH" fi roo@ubuntu:~$ roo@ubuntu:~$ cat .bashrc # ~/.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=; esac # uncomment for a colored prompt, if the termina 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/ then # W 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' # Add an "alert" alias for long running commands.
Use like so: #
sleep 10; alert alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' # 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 - then
. /etc/bash_completion fi roo@ubuntu:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
版权声明:本文内容由互联网用户自发贡献,版权归作者所有,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至: 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。
用云栖社区APP,舒服~
【云栖快讯】中办国办印发《推进互联网协议第六版(IPv6)规模部署行动计划》加快推进基于 IPv6 的下一代互联网规模部署,计划指出2025年末中国 IPv6 规模要达到世界第一,阿里云也第一时间宣布了将全面提供IPv6服务,那么在全面部署 IPV6 前,你需要了解都在这儿&&
为您提供简单高效、处理能力可弹性伸缩的计算服务,帮助您快速构建更稳定、安全的应用,提升运维效率,降低 IT 成本...
MySQL 是全球最受欢迎的开源数据库,阿里云MySQL版 通过深度的内核优化和独享实例提供稳定极致的数据库性能...
云数据库HybridDB(ApsaraDB HybridDB)是一种在线MPP大规模并行处理数据仓库服务。云数据...
社区之星年度评选,投票可抽奖
Loading...}

我要回帖

更多关于 ubuntu 显示环境变量 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信