2014-01-14 297 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