Directory Aliasing

Hello,

I need to rediret the directory location at run time as:-

If I type cd /dir1/dir2 then it should take me to /dir1/dir3 at run time.

Inside dir1, both dir2 and dir3 directories are present.

Could anyone guild me over it?

Thanks
Shubham

There are no good ways to alias a directory, except using symlinks.

So you need to explain carefully the difference between "run time" and other times. Plus.
You do realize that doing this will have major side effects, like not being able to ever get into /dir/dir2 during run time.

Hello,

By run time I mean, whenever the command below is executed:-

cd /dir1/dir2 then it should land me in /dir1/dir3.

As fas as I know, symbolic links can't be used for folders/directories. Its for files.

Please correct me If I am wrong and let me know further on it.

Thanks
Shubham

Symbolic links work just fine for folders. You can't hardlink a folder, but symlinks can link to anything. You can even make a symlink that goes nowhere if you really want. It's just a string, in the end.

ln -s /absolute/path/of/destination /absolute/path/to/source

Absolute paths are reccomended since it takes the destination path completely literally without considering the current working directory at all.

Note that under Solaris, you can also use lofs to mount a directory to another one.
eg:

# mount -F lofs /dir1/dir3 /dir1/dir2

Is this persistent? Will it disappear on reboot?