Server Fault is a question and answer site for system and network administrators. 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

The question could probably be reworded. What I would like to have is certain path, say /workingsrc to refer to a different real path per shell (bash) instance simultaneously.

So in an instance of bash I can do ls /workingsrc and get the contents of /foo/bar and in another instance that is running at the same time in the same machine do ls /workingsrc and get the contents of /foo/zoo.

Do you know if there is a way to do this? I'm using linux and bash.

share|improve this question
up vote 1 down vote accepted

Variant symlinks is what you want, but are only on *BSD and AFS filesystem. Working with environment variables is much easier (see Hyppy response).

share|improve this answer
You are right, this is exactly what I was looking for. Too bad they are not available in Linux. – Jacobo de Vera Mar 18 '11 at 13:51

You can probably do this with environment variables. For example: Shell 1:


Shell 2:


Back on shell 1:


You should still see /foo/bar on shell 1, even after setting the variable to a different value in shell 2.

share|improve this answer
You could probably add an alias to this so you don't distract people with the $ – Decado Mar 18 '11 at 13:21
An alias doesn't expand within a command unless it begins with the alias, though. For example, if you set $WORKINGSRC to an alias called aliaswrksrc, then "ls aliaswrksrc" won't work. You'd have to make a separate alias for each command you want to do, unless I'm mistaken. – Hyppy Mar 18 '11 at 13:24
Okay, i meant it's set to the correct value when you log into the shell. So as part of .bash_profile you do: export WORKING_DIR=/var/tmp; alias cdwork="cd $WORKING_DIR". Then cdwork will take me to what WORKING_DIR is set to at login to the shell time. – Decado Mar 18 '11 at 13:36
yes, currently I am using a env var with the work dir path in it, and a function that sets its value and updates all depending env vars. I also have shopt -s cdable_vars in my .bashrc so that I can do cd workingsrc anywhere and get to $workingsrc. I was looking for a next step from this setup. – Jacobo de Vera Mar 18 '11 at 13:43

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.