You are not logged in.

#1 2017-12-06 17:45:41

arsene
Member
Registered: 2017-12-06
Posts: 5

creating symlink to executable?

Is there a recommended (proper) way to create a symlink to an existing executeable?
Symlink should be in PATH to serve as an "alias/alternative" to given name.

There are some situations that I know is being handled, like java, python.
What about js, like (js24, node.js, rhino, ...)?

I'm thinking the following should serve as a pretty failsafe solution:

# ln -sf /usr/bin/rhino /usr/local/bin/js

Ideas?

Cheers,
arsene

Last edited by arsene (2017-12-06 17:47:31)

Offline

#2 2017-12-06 18:30:22

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: creating symlink to executable?

Don't do this, adjust your PATH as needed instead.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#3 2017-12-06 18:43:51

arsene
Member
Registered: 2017-12-06
Posts: 5

Re: creating symlink to executable?

Care to elaborate?

Offline

#4 2017-12-06 18:49:08

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: creating symlink to executable?

Example, add .local/bin  for things you installed using `pip install --user`:

zsh: path+="~/.local/bin"  
or if you use bash: PATH="$PATH:~/.local/bin"

Last edited by Mr.Elendig (2017-12-06 18:49:29)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2017-12-06 19:55:52

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: creating symlink to executable?

How does changing the PATH map js to rhino?

Offline

#6 2017-12-06 20:27:50

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: creating symlink to executable?

Because you create a symlink in your $HOME/bin or whatever?


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#7 2017-12-06 20:48:13

loqs
Member
Registered: 2014-03-06
Posts: 19,113

Re: creating symlink to executable?

Which works for that user but not system wide could also be achieved by an alias.
Is the aversion to the symlink making it system wide that js25 already provides /usr/bin/js so other arch packages can assume calling js meaning calling js25?
That issue would still exist though just for that one user.

Offline

#8 2017-12-06 20:51:59

arsene
Member
Registered: 2017-12-06
Posts: 5

Re: creating symlink to executable?

Probably my question's unclear. I'd like to make it syswide. Also the executable are already in the PATH, since those were put there by some package, just not by the name I'd like to use them. I'd like to be able to switch between variants. Something like /usr/bin/edit, but I don't want to create a symlink in /usr/bin for obvious reasons.

Is there anything under root's holy Sun why creating a symlink in /usr/local/bin wouldn't do just exactly what I've described?

Offline

#9 2017-12-06 20:56:35

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: creating symlink to executable?

arsene wrote:

Probably my question's unclear. I'd like to make it syswide.

Why? Does your machine have more than one user? If you want an alias, use an alias, not a symlink.

Offline

#10 2017-12-06 21:08:08

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: creating symlink to executable?

arsene wrote:

Probably my question's unclear. I'd like to make it syswide. Also the executable are already in the PATH, since those were put there by some package, just not by the name I'd like to use them. I'd like to be able to switch between variants. Something like /usr/bin/edit, but I don't want to create a symlink in /usr/bin for obvious reasons.

Is there anything under root's holy Sun why creating a symlink in /usr/local/bin wouldn't do just exactly what I've described?

Should be fine. It isn't the most robust way. There could be issues, but that depends on situations. What is your intent on making these symlinks? E.g., why are you aliasing rhino to js?


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#11 2017-12-06 21:57:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,867

Re: creating symlink to executable?

There's nothing wrong with this in general, but it's generally wrong to do it uninformed.

Potential issues:
1. a generic name up in the $PATH could ultimately shadow an actual binary of the same name down in the $PATH (js185 has /usr/bin/js which will be shadowed by your symlink)
2. some binaries check their name to adjust behavior (and typically provide various symlinks already)
3. entirely wrong way to handle an xy-problem, ie. what is the *actual* problem you're trying to solve?

Offline

#12 2017-12-06 23:44:35

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: creating symlink to executable?

loqs wrote:

Which works for that user but not system wide could also be achieved by an alias.
Is the aversion to the symlink making it system wide that js25 already provides /usr/bin/js so other arch packages can assume calling js meaning calling js25?
That issue would still exist though just for that one user.

I don't know *why* MrElendig feels user-specific PATH executables/symlinks are so superior to /usr/local/bin

I agree aliases are the way to go, for one, they will not typically be loaded into the environment of scripts etc. so if you shadow an actual command it should only do so in an interactive shell interpreter.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#13 2017-12-07 00:38:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: creating symlink to executable?

One further point in favor of aliases, is that they can be system-wide if you really want them to be (put them in /etc/profile or the like).  Though 2MD's question on how many users are on the machine is still relevant for whether this needs to be system-wide.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#14 2017-12-07 00:56:00

arsene
Member
Registered: 2017-12-06
Posts: 5

Re: creating symlink to executable?

I'm start to think I should ditch this idea.

2ManyDogs wrote:

If you want an alias, use an alias, not a symlink.

It's way harder to find where alias has been set and change it to something else. Also are you suggesting to add an alias in profile or adding it to each installed shell's rc file?

fsckd wrote:

why are you aliasing rhino to js?

I'd like to set it as a default javascript interpreter.

set wrote:

1. a generic name up in the $PATH could ultimately shadow an actual binary of the same name down in the $PATH (js185 has /usr/bin/js which will be shadowed by your symlink)

Shadowing would be an issue no matter what the solution is. I'm more concerned overwriting the original binary accidentally.

Last edited by arsene (2017-12-07 01:16:26)

Offline

#15 2017-12-07 00:59:27

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: creating symlink to executable?

arsene wrote:

It's way harder to find where alias has been set and change it to something else.

That's just silly. I'm done here. symlink your heart out.

Offline

#16 2017-12-07 03:22:48

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: creating symlink to executable?

arsene wrote:

It's way harder to find where alias has been set and change it to something else.

create a dotfile .aliases.sh to keep all your aliases at one place, and source it in your .bashrc

Last edited by Docbroke (2017-12-07 03:23:04)

Offline

Board footer

Powered by FluxBB