[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatic updating links?



On Tue, Jun 06, 2017 at 12:27:06PM +0100, Rodolfo Medina wrote:
I wish to create a link to a file that wouldn't break when that file is moved
on elsewhere in the filesystem or renamed, nay the link would automatically
`update' pointing at the new name/address of the file.  Is that possible?
Besides, I wish that form of automatic update also when moving or renaming the
directory where the link itself lives.

A hardlink might work here.

A symlink (which many people are familiar with) is, essentially, a small
file which says "I am a pointer to /bin/foo". A hardlink, however, is a
second name for a file ("I am both /bin/foo and /bin/bar"). A hardlink
is possible because of the disconnection between a file's directory
entry (i.e. it's name) and the file's contents.

With a hardlink, it is possible to perform certain actions without
breaking the link. You can move one of the files (this just changes that
particular directory entry), you can rename the directory holding the
file(s) (as this doesn't affect the directory entry at all). In certain
circumstances you can even edit the file - as there is only one "file
contents", both files will show identical changes immediately.

There are some restrictions, though. Some file editing operations
involve deleting the original and replacing it with the modified
version. This will break the hardlink (becasue you're essentially saying
"/bin/foo now points to this file" without updaing what /bin/bar points
to). Also, hardlinks are a file-system-specific feature - that is, you
can't hardlink two files on different filesystems.


Thanks for any help,

Rodolfo


--
For more information, please reread.

Attachment: signature.asc
Description: PGP signature


Reply to: