How to run a program without specifying the full path?

前端 未结 2 678
梦毁少年i
梦毁少年i 2021-01-25 16:59

How come when I type \"rails\", it won\'t work... but when I type \"/var/lib/gems/1.8/bin/rails\" it will work? How do I bind it so that I don\'t have to type the full path ever

2条回答
  •  长情又很酷
    2021-01-25 17:16

    You need to edit your $PATH environmental variable.

    For example, in your .bashrc:

    export PATH=$PATH:/var/lib/gems/1.8/bin
    

    Alternatively, you can use an alias, in your .bashrc:

    alias rails=/var/lib/gems/1.8/bin/rails
    

    Or you could even put the rails binary (or a symlink) to one of the directories listed in your $PATH. To see those directories, type echo $PATH.

提交回复
热议问题