Advanced

File Linking in Linux: Hard vs. Soft Links

Posted by nemilar on · 4 comments
TechThrob.com; By Jonathan DePrizio
Mail this story
Print this story

In Linux, there are two types of file links: hardlinks and softlinks. This article shows the difference between hard and soft links, how they work, and explains when you should pick a softlink over a hardlink.

Full Story

  Nav
» Read more about: Story Type: Tutorial

» Get new stories by e-mail: nightly or as they are published

« Return to the newswire homepage

  Related stories
» More like this

Comments (4)

Sure, they have their common uses, like mirroring the directory structure of the Xorg source code, or relocating configuration files under /etc.

But I like the ability to point /boot/vmlinuz to /usr/src/linux/arch/i386/boot/bzImage (which itself contains a symlink at /usr/src/linux). Since /boot isn't in its own volume, Grub's ext2 stage will merrily trace the path I provide, until it finds the kernel image. No more of this "copy to /boot, cd to /boot, erase symlinks, provide new symlinks" stuff; the only symlink to adjust is at /usr/src/linux, to point to the new source tree. Once I have the kernel built and the modules installed, I can reboot immediately to try the new kernel.
Nice trick. You can find them in my systems, which end up with 3 or 4 installs at a time using them to link storage partitions into user accounts. They get mounted in /mnt/ then linked to where ever I want them, I never have to think about it as the fstab entry stays the same for them regardless what install I'm booted into.

btw have I mentioned I despise grub2, autodetect that doesnt, and 40_custom which some distros refuse to protect so thusly gets overwritten?
@az:

If you're using Ext2/3/4, look into "chattr +i".
will do, thanks.

Anyone else have handy uses for symlinks?

Post a comment

A free account is needed to post. Write your comment here first: your text is kept in this browser while you sign up or log in, and is waiting for you when you come back.

Your message:
|||||
10
Markdown: **bold**, *italic*, [text](https://link), - lists, > quotes, $x^2$ for math. Formatting help

Sign up and post (it is free)  or  Log in and post