Is there an equivalent of .lnk in Linux?

11

2

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?

sealz

Posted 2011-07-14T14:29:29.023

Reputation: 2 034

Answers

15

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

Diogo

Posted 2011-07-14T14:29:29.023

Reputation: 28 202

@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. – djhaskin987 – 2016-01-06T21:40:58.687

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 – 2016-10-01T23:18:53.470

@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.] – ctrl-alt-delor – 2016-10-20T18:38:38.687

4However, 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. – Factor Mystic – 2011-07-14T19:45:38.750

2Symlinks 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! – Nathan Moos – 2011-07-15T00:09:11.023

26

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.

user1686

Posted 2011-07-14T14:29:29.023

Reputation: 283 655

4Oh, the superiority of Posix-based systems! – Roy Tinker – 2011-07-14T17:18:53.827

@Roy: There's always Plan9. – user1686 – 2011-07-14T17:49:26.590

That looks interesting, @grawity. I'll check it out. Thanks! – Roy Tinker – 2011-07-14T17:57:04.397

3there is the third one, hard link – Lie Ryan – 2011-07-14T18:41:28.360

@Lie: Yes, but it's not very widely used as a .lnk alternative due to the limitations. – user1686 – 2011-07-14T19:12:49.170