Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unix PATH override commands

Let's say my PATH="/usr/bin ... /root/.rbenv/shims"

I have an executable (ruby) in /usr/bin and /root/.rbenv/shims. How would I make the ruby in /root/.rbenv/shims be called?

like image 260
LanguagesNamedAfterCofee Avatar asked Nov 21 '11 02:11

LanguagesNamedAfterCofee


People also ask

What is PATH command in Unix?

The PATH environment variable is a colon-delimited list of directories that your shell searches through when you enter a command. Program files (executables) are kept in many different places on the Unix system. Your path tells the Unix shell where to look on the system when you request a particular program.

How do I append a PATH in Unix?

We can add a new path for all users on a Unix-like system by creating a file ending in . sh in /etc/profile. d/ and adding our export command to this file. All of the scripts in /etc/profile.

How do I change Bash PATH?

For Bash, you simply need to add the line from above, export PATH=$PATH:/place/with/the/file, to the appropriate file that will be read when your shell launches. There are a few different places where you could conceivably set the variable name: potentially in a file called ~/. bash_profile, ~/.


1 Answers

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

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

(Before running this command, you must be sure PATH already exists -- if it doesn't, it adds the current working directory to your PATH as well, which is almost always a mistake.)

like image 177
sarnold Avatar answered Oct 19 '22 08:10

sarnold