Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing between multiple executables with same name in Linux

Tags:

linux

path

The system I am using has gnuplot installed in /usr/bin. I don't have root, but I needed a newer version of gnuplot, so I installed it to $HOME/usr/bin.

I added $HOME/usr/bin to my path, but it still executes the one in /usr/bin if I just use the gnuplot command. I'd rather not have to specify $HOME/usr/bin/gnuplot every time I have to use it.

How do I tell Linux to use the one in my home directory, and not the one in /usr/bin?

like image 950
Neal Avatar asked Jan 05 '09 15:01

Neal


4 Answers

Executables are found in PATH order. You need to prepend ${HOME}/usr/bin to your path, like so:

export PATH="${HOME}/usr/bin:$PATH"
like image 177
Bombe Avatar answered Nov 16 '22 22:11

Bombe


Executables are found in PATH order. Your PATH apparently is set up such that /usr/bin precedes ~/usr/bin/.

like image 28
MSalters Avatar answered Nov 16 '22 23:11

MSalters


Besides modifying the PATH as has been explained, you can also use aliases like this (in BASH)

alias gn=$HOME/usr/bin/gnuplot

then you just run it with

gn
like image 10
Vinko Vrsalovic Avatar answered Nov 17 '22 00:11

Vinko Vrsalovic


What Bombe says is ok. I would add that you should declare your user specific PATH entries inside your user's bashrc ($HOME/.bashrc), so your PATH settings only apply to your user.

like image 4
Fernando Miguélez Avatar answered Nov 16 '22 23:11

Fernando Miguélez