首页 文章

找不到PATH中的可执行文件

提问于
浏览
1

我有一个位于PATH的可执行文件,但是当我输入命令时找不到它 .

$PATH 的结果是:-bash:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0/bin:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0@global/bin:/Users/ aridyckovsky / .rvm /红宝石/红宝石2.1.0 /斌:/Library/Frameworks/Python.framework/Versions/3.3/bin中:/ opt / local / bin目录中:/ opt / local / sbin中:在/ usr / bin中:/斌:/ usr / sbin目录:/ sbin目录:在/ usr / local / bin目录中:/ opt / X11 / bin中:在/ usr /本地/ git的/ bin中:在/ usr /本地/ MySQL的/斌:/Users/aridyckovsky/.rvm/ bin:没有这样的文件或目录`

具体来说,我试图在/ usr / local / bin中执行 mongod ,但结果是 -bash: mongod: command not found . 但是,我可以在同一位置运行其他可执行文件 . 有任何想法吗?

1 回答

  • 2

    当您尝试将 $PATH 作为命令执行时,您将收到该错误 .

    $ $PATH
    bash: /home/glennj/bin:...:/opt/tcl/8.6/bin: No such file or directory
    

    在bash中,使用 type 内置来查找内容:

    $ type mongod
    mongod is /usr/bin/mongod
    

    使用 type -a 也可以显示别名和功能

    $ type -a ls
    ls is aliased to `ls -F'
    ls is /bin/ls
    $ type -a git
    git is a function
    git () 
    { 
        case "$1" in 
            push | pull)
                if (( $# == 1 )); then
                    local branch=$(git_current_branch);
                    if [[ -n $branch ]]; then
                        set -- $1 origin "$branch";
                        echo git "$@";
                    else
                        echo "You're not in a git-managed directory" 1>&2;
                        return;
                    fi;
                fi
            ;;
        esac;
        command git "$@"
    }
    git is /usr/bin/git
    

相关问题