红联Linux门户
Linux帮助

环境变量问题

发布时间:2009-06-10 09:02:41来源:红联作者:adminchen
我用以下命令在终端下输入打不开gmplayer播放器
播放器目录在 /opt/mplayer/bin/gmplayer
用这个命令添加变量路径后也不行。
env PATH=&PATH:/opt/mplayer/bin

[root@localhost ~]# gmlayer
bash: gmlayer: command not found
[root@localhost ~]# ./gmplayer
bash: ./gmplayer: 没有那个文件或目录


请问这是怎么回事啊
文章评论

共有 10 条评论

  1. root_bbk 于 2009-06-13 11:12:49发表:

    vi ~/.bashrc

    PATH=$PATH:$HOME/bin 加上你的路径 , PATH=$PATH:$HOME/bin:/opt/mplayer/bin

    需要logout 再 login ,

    env | grep mplayer 查看有没有你的路径

  2. adminchen 于 2009-06-11 10:28:16发表:

    照楼的朋友方法可以了。export PATH=$PATH:/opt/mplayer/bin
    但不知在bashrc这个用户主目录里面哪里加,谢谢!

    # /etc/bashrc

    # System wide functions and aliases
    # Environment stuff goes in /etc/profile

    # By default, we want this to get set.
    # Even for non-interactive, non-login shells.
    if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
    umask 002
    else
    umask 022
    fi

    # are we an interactive shell?
    if [ "$PS1" ]; then
    case $TERM in
    xterm*)
    if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
    PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
    else
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
    fi
    ;;
    screen)
    if [ -e /etc/sysconfig/bash-prompt-screen ]; then
    PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
    else
    PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
    fi
    ;;
    *)
    [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
    ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
    fi

    if ! shopt -q login_shell ; then # We're not a login shell
    # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
    if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
    if [ "$2" = "after" ] ; then
    PATH=$PATH:$1
    else
    PATH=$1:$PATH
    fi
    fi
    }

    # Only run profile.d scripts if we are no login shell and interactive
    if [ "$PS1" ]; then
    for i in /etc/profile.d/*.sh; do
    if [ -r "$i" ]; then
    . $i
    fi
    done
    fi
    unset i
    unset pathmunge
    fi
    # vim:ts=4:sw=4

  3. jagub 于 2009-06-10 21:30:24发表:

    在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
    的前面加上
    PATH=$PATH:/opt/mplayer/bin

  4. fkzh2651 于 2009-06-10 19:53:15发表:

    上面请大侠帮一下,谢谢

  5. adminchen 于 2009-06-10 12:49:52发表:

    怎么没有人知道吗?

  6. adminchen 于 2009-06-10 09:24:47发表:

    上面请大侠帮一下,谢谢!

  7. adminchen 于 2009-06-10 09:19:50发表:

    看到过LINUXredhat 9 书是介绍是用这个命令 env PATH=&PATH:/opt/mplayer/bin
    fedora中应该不行的。
    还有修改profile文件:.bashrc文件
    请问在里面什么地方修改,上面,下面,中间。

    # /etc/profile

    # System wide environment and startup programs, for login setup
    # Functions and aliases go in /etc/bashrc

    pathmunge () {
    if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
    if [ "$2" = "after" ] ; then
    PATH=$PATH:$1
    else
    PATH=$1:$PATH
    fi
    fi
    }

    # ksh workaround
    if [ -z "$EUID" -a -x /usr/bin/id ]; then
    EUID=`id -u`
    UID=`id -ru`
    fi

    # Path manipulation
    if [ "$EUID" = "0" ]; then
    pathmunge /sbin
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
    fi

    # No core files by default
    ulimit -S -c 0 > /dev/null 2>&1

    if [ -x /usr/bin/id ]; then
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
    fi

    HOSTNAME=`/bin/hostname`
    HISTSIZE=1000

    if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
    fi

    export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

    for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
    . $i
    fi
    done

    unset i
    unset pathmunge

  8. Htgiot 于 2009-06-10 09:19:27发表:

    好也

  9. adminchen 于 2009-06-10 09:09:33发表:

    自己已经解决了。
    export PATH=$PATH:/opt/mplayer/bin

  10. linsi 于 2009-06-10 09:06:12发表:

    改变 PATH 后要将它 export 到环境变量中以供其它地方调用:
    [root@localhost ~]# export PATH=$PATH:/opt/mplayer/bin