5

Is there an equivalent to Microsoft Windows' shortcuts in Ubuntu?

I am already aware of both hardlinks and symlinks but they miss one feature I find really interesting. If the target file is moved the shortcut is updated and knows the new location of the file. Hardlinks I believe have this functionality but only on the same file system while symlinks do not.

Is there a link that automatically updates the target location?

Braiam
  • 67,791
  • 32
  • 179
  • 269
Jordan Ketterer
  • 331
  • 1
  • 2
  • 9
  • 2
    I disagree with the duplicate suggestion here. They both mention the same stuff but they have inverse aims. – Oli Mar 25 '14 at 17:12
  • I've seen a lot of applications that correct wrong shortcuts in Windows. May be you are using one of them. I never seen that Explorer "automatically updates the target location". – Danatela May 12 '14 at 08:18
  • I don't see that the answers so far comprehend what a Windows-shortcut is. Short-cuts offer things nix symbolic links can/do/will-never do. fyi: short-cuts are extremely effecive on the command-line. I use use the (new) symlnk command when that behaviour matches the use-case we need. That said: as a heavy short-cut user, the only auto update I've seen is-a gotcha* -- When TypeId target(s) move to the RECYCLE-BIN ... Windows may point links to a file in the trash. A good check it "command --version" when you delete shortcut. – will Apr 17 '16 at 14:02

2 Answers2

2

Is there an equivalent to Microsoft Windows' shortcuts in Ubuntu?

Lets remember that shortcuts in Windows (those files with a .lnk extension) are files with metadata which represent a file/directory redirection only recognized by the Windows file manager, explorer.exe.

Linux, ergo Ubuntu, doesn't have the same behavior. Instead of a file that can only be interpreted by only the file manager, it uses the Freedesktop specification of .desktop files. There's a counterpart for directories which uses .directory extension, but the behavior "you open one of these files, and some file/directory gets executed" is the same as explorer shortcuts. These are supported by most (if not all) file managers available in Ubuntu and Linux.

You can read the complete specification in Freedesktop.org

If the target file is moved the shortcut is updated and knows the new location of the file.

Neither, Freedesktop and Windows Explorer, have such functionality. The only thing that is able to realize it are hard links.

Braiam
  • 67,791
  • 32
  • 179
  • 269
  • With windows shortcut the target is somehow connected to the file not location. It could be using hardlinks maybe. In windows I created a shortcut for the file "C:\users\ketterer\downloads\casestudy.pdf I then moved the shortcut to the desktop becasue that is where i wanted it to be used, then i moved the pdf itself to the parent directory with cut using ctrl+x and then Ctrl+v. I then opened the shortcut just fine and the target in properties had changed to "C:\users\ketterer\casestudy.pdf Sorry for the comment a year later. – Jordan Ketterer Dec 14 '14 at 05:03
  • I just did another test, i moved the pdf to another drive and tested the shortcut again, it worked and target automatically updated to "E:\casestudy.pdf" then I renamed the file to case.pdf and it still works – Jordan Ketterer Dec 14 '14 at 05:07
  • only recognized by the Windows file manager, explorer.exe *Total Commander user smiles*. – Nils Lindemann Apr 08 '21 at 07:18
0

You can create a .desktop file. It's just like Windows shortcuts. You can add your own icon, change the name, add description and so on. And you can also add the name and description for different languages in the same shortcut.

More... Creating a .desktop file for a new application

kv1dr
  • 1,381
  • 1
    A .desktop file won't work if the target is moved, so this is not a correct answer to the question which is: Is there a sort of target which "still works" after the target is moved? – jdthood Mar 28 '14 at 08:51