12

When creating a shortcut in windows it makes a .lnk file.

I have researched and it seems these are openable in linux(with some tweaking). Does Linux have an equivalent? If so, whats the extension?

2 Answers 2

16

Linux doesn't work with file extensions. However, you can make a shortcut on Linux using "symbolic links". They are something like a "pointer" to a file.

Take a look at here to see how to do it:

How do I create a symbolic link?

ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]

For example:

ln -s /usr/local/apache/logs ./logs
5
  • 4
    However, unlike a Windows shortcut, a symbolic link will break when the target file is moved... which is pretty much the principal reason you'd use a shortcut. So strictly speaking a linux symlink is not the equivalent of a Windows shortcut, it's the equivalent of a Windows symlink. Jul 14, 2011 at 19:45
  • 2
    Symlinks are my favorite tool for keeping my files organized. Linux symlinks are kept in sync with the target file no matter what program reads them! Jul 15, 2011 at 0:09
  • @FactorMystic If you make the symlink point to an absolute location in the filesystem, this is not the case. ln -s /usr/local/apache/logs ./logs will make a symlink to /usr/local/apache/logs, and will not be broken when you move it around. Jan 6, 2016 at 21:40
  • The environment maintains the symbolic links in the path, but Windows changes the environment's path for shortcuts. (E.g., if a link targets /tmp and resides in the file /home/user/temp, a symbolic link would access the directory /tmp/upload as /home/user/temp/upload, whereas a shortcut would first change the environment directory to /tmp and then access /tmp/upload directly.) I don't know of any Linux feature that behaves this way.
    – palswim
    Oct 1, 2016 at 23:18
  • @FactorMystic If you move the target of a shortcut, then it will always break. If you move the link (symlink or shortcut), it may break, and this depends on a number of factors. More just the link: symlink with absolute path and shortcut will be fine; symlink with relative path will break. Move link and target together (i.e. whose sub-tree) symlink with absolute path and shortcut will break, symlink with relative path will be fine. [so the comparison is not between symlink and shortcut, but between relative and absolute path.] Oct 20, 2016 at 18:38
28

Linux has two types of links:

  • .desktop files: created by graphical file managers. They are similar to Windows .lnk shortcuts, minus the automatic updating. They, like shortcuts, only work inside the GUI file manager program.

  • Symbolic links: created with ln -s target link on Linux and mklink link target on Windows. These can be used transparently by any program.

5
  • 4
    Oh, the superiority of Posix-based systems!
    – Roy Tinker
    Jul 14, 2011 at 17:18
  • @Roy: There's always Plan9.
    – user1686
    Jul 14, 2011 at 17:49
  • That looks interesting, @grawity. I'll check it out. Thanks!
    – Roy Tinker
    Jul 14, 2011 at 17:57
  • 3
    there is the third one, hard link
    – Lie Ryan
    Jul 14, 2011 at 18:41
  • @Lie: Yes, but it's not very widely used as a .lnk alternative due to the limitations.
    – user1686
    Jul 14, 2011 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.