2014-01-14 194 views
1

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

$PATH结果是: -bash:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0/bin:/Users/aridyckovsky/.rvm/gems/[email protected]/斌:/Users/aridyckovsky/.rvm/rubies/ruby-2.1.0/bin:/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的/ bin中:/用户/ aridyckovsky/.rvm/bin:没有这样的文件或目录`

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

+0

那么,是什么'ls -l命令在/ usr /本地/ bin/mongod'说? – nos

+0

做一个'ls -l完整路径到你的文件并发布到这里。 – michael501

+0

结果是:'lrwxr-xr-x 1 aridyckovsky admin 34 Nov 11 13:43/usr/local/bin/mongod - > ../ Cellar/mongodb/2.4.8/bin/mongod' – adyckovsky

回答

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 "[email protected]"; 
       else 
        echo "You're not in a git-managed directory" 1>&2; 
        return; 
       fi; 
      fi 
     ;; 
    esac; 
    command git "[email protected]" 
} 
git is /usr/bin/git 
+0

+1不太确定它是否回答了这个问题,但是像'提示'类型。知道'输入'''哪个'为bash,但不知道'a'的标志。绝对重写哪个='type -a'在我的bash上。 – BroSlow