Symbolic links vs Windows shortcuts?

9,207

Solution 1

Yes and no.

In order to understand the vagaries here, you need to understand the relationship between the inode table, and data written to disk.

Windows shortcuts are path data contained in regular files. Think of them like text files which only contain a URI for a file. From Wikipedia:

Shortcuts are treated like ordinary files by the file system and by software programs that are not aware of them. Only software programs that understand shortcuts (such as the Windows shell and file browsers) treat them as references to other files.

Another difference are the capabilities of the mechanism: Microsoft Windows shortcuts normally refer to a destination by an absolute path (starting from the root directory), whereas POSIX symbolic links can refer to destinations via either an absolute or a relative path. The latter is useful if both the location and destination of the symbolic link share a common path prefix, but that prefix is not yet known when the symbolic link is created (e.g., in an archive file that can be unpacked anywhere).

Microsoft Windows application shortcuts contain additional metadata that can be associated with the destination, whereas POSIX symbolic links are just strings that will be interpreted as absolute or relative pathnames.

Windows Vista, 7 and 8 also support symbolic links natively under NTFS

POSIX-Compliant symbolic links are not files. Instead, they are entries into the inode table which are automatically resolved by the file system. Any software program, upon accessing a symbolic link, will see the target instead, whether the program is aware of symbolic links or not.

Solution 2

Symbolic links are much like Windows shortcuts. They are like an alias that points to the real object in the filesystem. If the object moves or is deleted, the link becomes broken.

Both windows and Linux have hard links, which are very different. I haven't used Windows since XP, and at that time, there was no UI for hard links, but there was an API, and an app could create a hard link (it could also be done by a user using Cygwin).

A hard link is another full-fledged object in the file system. You can have multiple links, and all of them act the same. They all point to the same storage, though. If you delete one, and the other will still exisst, the storage will not be deleted until you delete all the links.

Share:
9,207

Related videos on Youtube

becko
Author by

becko

Updated on September 18, 2022

Comments

  • becko
    becko over 1 year

    What are the differences between symbolic links in Ubuntu and Windows shortcuts? Are they analogous concepts? Or is there something in Ubuntu that resembles more Windows shortcuts?

  • Deepak Verma
    Deepak Verma almost 10 years
    Good answer. If I had been slower, I would not have bothered to answer. But no insult intended, your answer may have been a bit too technical for a lot of people, so I'll leave mine, too.
  • James S.
    James S. almost 10 years
    Thanks - the only reason I even knew the subtleties here is because I used to run into problems twenty years ago (the last time I used Windows - haha!) Your answer definitely hits the immediate question, the big difference is simply where the link data is stored: in a regular file vs. in the inode table.
  • Deepak Verma
    Deepak Verma almost 10 years
    20 years since you used Windows?! What was that, NT 4? My mind refuses to even think about any version before that! :-)
  • James S.
    James S. almost 10 years
    I remain happy not having though about any versions since, either. ;D