Unix PATH Override Commands

Say my PATH="/usr/bin ... /root/.rbenv/shims"

I have an executable file (ruby) in /usr/bin and /root/.rbenv/shims . How can I call ruby ​​in /root/.rbenv/shims ?

+4
source share
2 answers

Put /root/.rbenv/shims first in PATH :

 export PATH=/root/.rbenv/SHIMS:$PATH 

(Before you run this command, you must be sure that PATH already exists - if it is not, it adds the current working directory to your PATH , which is almost always an error.)

+7
source

Use the absolute path:

 $ /root/.rbenv/shims/ruby ... 

If you do this from a shell script, use

 #!/root/.rbenc/shims/ruby 

like shebang

+1
source

Source: https://habr.com/ru/post/1382207/


All Articles