Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symbolic link without expanding $HOME or "~"?

Tags:

People also ask

What is the difference between Hardlink and symbolic link?

Symbolic links link to a path name. This can be anywhere in a system's file tree, and doesn't even have to exist when the link is created. The target path can be relative or absolute. Hard links are additional pointers to an inode, meaning they can exist only on the same volume as the target.

What characteristic does a symbolic link have?

A symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.

What is a dangling symbolic link?

A symbolic link (also known as a soft link) may point to an existing file or to a nonexistent one; the latter case is known as a dangling link.

How do I create a soft symbolic link?

Use the -s option to create a soft (symbolic) link. The -f option will force the command to overwrite a file that already exists. Source is the file or directory being linked to. Destination is the location to save the link – if this is left blank, the symlink is stored in the current working directory.


the basic idea is that I want to link to path that's relative to $HOME, rather than explicitly expand the $HOME variable, as I want to make sure the link works on multiple machines, e.g.,

when I do

ln -s ~/data datalnk

I want it to be directed to directory /home/user/data on one machine which has a user $HOME of /home/user, and to /home/machine/user/data on another machine which has a user $HOME of /home/machine/user/data.

I cannot create a symbolic link on the second machine using

ln -s /home/machine/user /home/user

because I don't have the permission to do that, and I cannot link relative paths as the two machines have different hierarchies of directories.

anyideas on possible ways to fix or circumvent this?

EDIT:

what I am really trying to accompanish is to make the same link work on two macihnes, where the targets have the same directories in terms of their relative path to $/HOME only, not their absolute path, and not their relative path to the link either.