4

When I mainly used Windows, to make a shortcut, I could use a regular file detailing where it linked to, with the extension .lnk or .url

Now, on Linux, I mainly use symbolic links, which are a filesystem-specific feature. Linux doesn't seem to have much support for file-based shortcuts, and Windows doesn't seem to have much support for symlinks.

I can see the advantage to using file based shortcuts (Can be used on any file system).

My question is, Why does linux use symlinks over file-based shortcuts, and on linux, how can I create shortcuts on file systems which don't support symlinks (eg FAT32)?

9
  • 2
    you should look up NTFS junction links.
    – strugee
    Sep 17, 2013 at 3:57
  • 2
    also, I've never heard of a GNU/Linux filesystem that doesn't do symlinks. if you're using FAT my advice would be to get a better filesystem (I realize this is cheeky and useless, but it's true).
    – strugee
    Sep 17, 2013 at 3:58
  • Most flash drives and sd cards are formatted with fat32 or vfat/fat64. Also, that was just an example. Also, a common filesystem is useful for transferring files between operating systems.
    – Mikemk
    Sep 17, 2013 at 6:15
  • I know. FAT is a pretty terrible filesystem, but I realize it's useful - it was a joke.
    – strugee
    Sep 17, 2013 at 7:01
  • 1
    Just to get your facts straight: Windows does support symlinks, NTFS supports symlinks and windows even ships with commands to create symlinks by default.
    – Marco
    Sep 17, 2013 at 7:59

2 Answers 2

1

Symlinks are used because of two reasons:

  1. It barely uses space on the hard disk. On filesystems where the metadata are reserved during creation (e.g., the ext2/3/4 family), symlinks is wholly contained as an inode in the filesystem metadata table.

  2. It's completely transparent. See explanation below:

Let's say I in /etc I created a symlink varlink pointing to /var. With symlinks, I can do cd /etc/varlink/lib. If I then do an ls, I would see the contents of /var/lib (that is, the "/etc/varlink" part is 'replaced' with "/var"). I can go deeper to /etc/varlink/lib/dbus, in which I will see the contents of /var/lib/dbus. Yet, even though what I'm seeing is actually the contents of the latter, the $CWD (Current Working Directory) is still the former.

Similarly when symlinks are against files. Let's say that /etc/fstab is a symlink to /opt/fstab. I can do all operation against /etc/fstab (e.g., cat the contents, or perform sed against its contents) without having to first decode it to find the actual file it's symlinking to. The filesystem behind the scenes will take care of I/O redirection to the actual file.


And the answer to the second question: I don't think that is possible at all. At least, not via the shell.

Within a GUI, however, it is possible to have a program handle Windows' ".lnk" files, to redirect the file browser to somewhere else. But I'm not sure if such program is ever made.

4
  • You haven't answered the second part - Is it possible (and how) to use shortcuts on filesystems without symlink support on linux?
    – Mikemk
    Sep 17, 2013 at 6:17
  • I've edited my answer.
    – pepoluan
    Sep 17, 2013 at 10:09
  • It is surely possible to implement “shortcuts” in an application, e.g. the shell. But symlinks are supported by the operating system, meaning no changes to any application have to be made to support symlinks. It's not at all related to having a GUI or not. To be able to compete with symlinks it would have to be implemented in the kernel (e.g. as a module) to be transparent to applications. But what problem would that solve that hasn't been solved already?
    – Marco
    Sep 17, 2013 at 14:45
  • Erm, no. If transparent support for microsoft style links were implemented in Linux, the logic would sit in the filesystem code, not in the kernel. If you really need the capability then have a look at FUSE
    – symcbean
    Jul 21, 2016 at 22:32
0

Advantages of sym-links:

  1. transparency: Only management software has to know of the existence of sym-links. They just work. Shortcuts only work if the software trying to open them knows that they are a short cut. Syn-links work for all software, including legacy software.

  2. chain-able: A sym-link will allow a link to a link to a link …

  3. quicker: They are often stored in the inode (this may not always be true), making them quicker to look up.

Disadvantages:

  1. Additional meta-information can be stored in a short-cut.

  2. File-system support is not needed.

  3. Instead of updating your file-system, you update every single other program in the system, this allows you to sell people the software that they already have, but with short-cut support, thus increasing revenue. (this advantage relies on your users not being free, you must have licensed the software under a proprietary licence.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .