Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Ubuntu (and Windows as well), I've noticed that whenever I create a file shortcut, and then move the file, the shortcut stops working, and becomes "broken". Is it possible to create a file shortcut in such a way that the shortcut will automatically point to the file's current location, instead of breaking whenever the file is moved?

share|improve this question

migrated from askubuntu.com Aug 24 '12 at 4:09

This question came from our site for Ubuntu users and developers.

    
This is a cross-platform issue, and not just an Ubuntu-specific issue, but I decided to post it here because I'm currently trying to solve this problem on Ubuntu. –  Anderson Green Aug 24 '12 at 2:19
    
It looks like this program might do something like this, but it only works on Windows: download.cnet.com/Broken-Shortcut-Fixer/… –  Anderson Green Aug 24 '12 at 2:22

1 Answer 1

up vote 4 down vote accepted

Use the ln (link) command without the -s (symbolic) switch. The link will persist when moving the file within the file system.

ln foo baz
mv foo bar

baz will still link to the file originally known as foo.

share|improve this answer
    
There are some restrictions though: hard-links only work within the same filesystem and it's not possible to make hard-links to directories. –  Sergey Aug 24 '12 at 2:34
    
@ubfan1 Can you explain what xx, lxx, and yy are supposed to represent here? Should they each be substituted with file names, or left as-is? –  Anderson Green Aug 24 '12 at 3:43
    
@AndersonGreen: I took the liberty of changing the placeholder to "foo bar baz" for intended clarity. –  Daniel Andersson Aug 24 '12 at 8:29
    
@DanielAndersson Is it possible to do this on Windows, as well as Unix-like operating systems? –  Anderson Green Aug 24 '12 at 18:38
    
@AndersonGreen: Well, all POSIX systems as well as NTFS has support for hard links. I have never used it in a Windows context personally, so I don't know how it works in practice, though. There is a command line tool mklink that creates hard links. If you want a GUI, you probably need third party software. –  Daniel Andersson Aug 24 '12 at 20:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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