Understanding Symbolic Links

I am a newbie to using symlinks, so I want to make sure I understand what they do. I’m trying to test out a tutorial I found on a Linux Mint community page for creating a shared data partition between OSes. I have successfully linked the directories on the data partition to those in my /home directory (Note: I am using a test installation for this. All my data is safely on another drive).

I downloaded some test documents from the Net (Manjaro User Guides) to the Downloads in /home. They showed up in both ~/Download and the corresponding directory on the data partition as expected. When deleted the files from ~/Downloads, they also disappeared from the data partition.

If I’m understanding this right. The symbolic links are NOT storing the files saved to them and copying to the data partition. The files are stored to the data partition and the symlink merely displays its contents; like a mirror. So when I go to the symlink and see a file displayed there, I’m actually looking at a file stored on the data partition. Anything I do to that file from the symlink side will be affecting the file on the data partition. If I delete it, it will be deleted from the data partition just as if I had deleted it directly from the data partition manually.

Is my understanding correct?

1 Like

Close. :slight_smile:

If the symlink points at a directory and you delete a file under the symlinked directory, then you are correct. But a deletion on the symlink itself will only delete the symlink, not the directory or file it points at. :wink:

:arrow_down:

ln -s sourcedir symlinkdir
rm -f symlinkdir/file01  # → deletes the file sourcedir/file01
rm -f symlinkdir         # → deletes "symlinkdir" but leaves "sourcedir" intact

It is important to realize in this regard that a symlink, too, is a file, with its own inode in the filesystem. :wink:

2 Likes

If I understand you correctly then yes.

I moved most of my biggest folders to another partition (Videos, Download, Music) and then symlinked them to Home. Works great.

1 Like

Could you link to it so we’re all on the same page (pun not intended :laughing:)?

I tried, but the forum said I wasn’t allowed to post links.

That’s odd. I tried deleting a file under the symlink and it appeared to delete the file on the data partition.

You can use the Preformatted text button to do it like this:

https://coolwebsite.com

Here’s the tutorial I was working from:

https://community.linuxmint.com/tutorial/view/1609

For some more background context, I found it through this Linux Mint support thread. I essentially want to replicate what the OP is trying to do with his rig:

https://forums.linuxmint.com/viewtopic.php?t=286796

P.s. Why is there an Insert Hyperlink option if posting links not allowed?

Exactly like @aragorn said:

1 Like

Okay, I must have misinterpreted that second sentence. It works the way I thought it did.

To me symlinks always felt like windows ‘shortcuts’ but with substantially better functionality. Being able to symlink in entire directories for use by software is incredibly useful.

In Windows, the “shortcut” is implemented only in the GUI ─ and not all applications know how to deal with them ─ while in UNIX, a symbolic link is implemented at the level of the underlying filesystem itself ─ provided that it is a POSIX filesystem, of course, because FAT-based filesystems and NTFS don’t support symbolic links. :wink:

1 Like

Substantially better functionality.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.