Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have built my app for different architectures and would like to create a "dynamic symlink" which takes me to the right version based on a variable.

If the machine I am currently logged in to, is x86, then the symlink should take me to that build.

A mocked example of what I want to do:

$ uname -i

$ ls -ltr 
lrwxr-xr-x  1 dogbane gg     4 Feb 16 15:40 mylink -> @sys/
drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 x86_64/
drwxrwxr-x  2 dogbane gg  2048 Feb 16 15:40 i386/

$ cd mylink

$ pwd -P

Is this possible?

I know I can use cd $(uname -i), but want something simpler.

share|improve this question
Are you familiar with OpenAFS? Because it uses @sys in exactly that way, even using '@sys'. If so, are you looking for an alternative to OpenAFS? – jsbillings Feb 16 '11 at 16:04
@jsbilling I'd like to know if this is possible on a standard filesystem, without AFS. I used to work on AFS a long time ago and could do this, hence why I asked. – dogbane Feb 16 '11 at 16:28
I figured as much. I know of no other filesystem that has 'magic' symlinks other than NetBSD's vfs.generic.magiclinks setting. (daemon-systems.org/man/symlink.7.html) – jsbillings Feb 16 '11 at 17:34
There are such environments for e.g. Ruby and Perl, so that you can choose which version to use when you're testing things. You might find some inspiration at rvm.io/rubies . – Jenny D Apr 10 '14 at 10:29

This feature is supported by DragonFly BSD, where it is called variant symlinks. See man varsym and man ln for details.

share|improve this answer

Symbolic links are static: the filesystem just stores a string, and accesses to the symbolic link are redirected to the file whose name (relative to the location of the symlink) is that string.

It would be simple to write a FUSE filesystem exposing such dynamic symlinks, but I don't know of an existing one.

share|improve this answer

I assume this is binaries, so I would do it with a PATH variable rater than symlink.


If you are using a tool like cfengine or puppet. A symlink to the appropriate directory can be created based on the system architecture.

share|improve this answer

If you just want a simpler syntax to type than:

cd $(uname -i)

You could put it in a variable like:

 s=`uname -i` 

in your login script, so you can just do

 cd $s

When you want to cd

share|improve this answer

symlink is essentially a file with special flag which contains some path, and this path interpreted as is, so you can not make one symlink to point to other locations in that way. But you still may write script that will run apropriate build.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.