I understand the technical difference between symlinks and hardlinks, this is a question about their use in practice, particularly I'm curious to know why both are used in seemingly similar conditions: the /bin directory.
Here's a fragment its listing on my system:
~$ ls -lai /bin
total 10508
32770 drwxr-xr-x 2 root root 4096 Jun 14 11:47 .
2 drwxr-xr-x 28 root root 4096 Sep 6 13:15 ..
119 -rwxr-xr-x 1 root root 959120 Mar 28 22:02 bash
2820 -rwxr-xr-x 3 root root 31112 Dec 15 2011 bunzip2
127 -rwxr-xr-x 1 root root 1832016 Nov 16 2012 busybox
2820 -rwxr-xr-x 3 root root 31112 Dec 15 2011 bzcat
6191 lrwxrwxrwx 1 root root 6 Dec 15 2011 bzcmp -> bzdiff
5640 -rwxr-xr-x 1 root root 2140 Dec 15 2011 bzdiff
5872 lrwxrwxrwx 1 root root 6 Dec 15 2011 bzegrep -> bzgrep
3520 -rwxr-xr-x 1 root root 4877 Dec 15 2011 bzexe
6184 lrwxrwxrwx 1 root root 6 Dec 15 2011 bzfgrep -> bzgrep
5397 -rwxr-xr-x 1 root root 3642 Dec 15 2011 bzgrep
2820 -rwxr-xr-x 3 root root 31112 Dec 15 2011 bzip2
2851 -rwxr-xr-x 1 root root 10336 Dec 15 2011 bzip2recover
6189 lrwxrwxrwx 1 root root 6 Dec 15 2011 bzless -> bzmore
5606 -rwxr-xr-x 1 root root 1297 Dec 15 2011 bzmore
I indented the hardlinks to the same inode for better visibility.
So are symlinks used in case of bzcmp, bzegrep, bzfgrep, bzless and hardlinks in case of bzip2, bzcat, bunzip2?
They are all regular files (not directories), reside inside one filesystem, are system utilities and are even made for working with the same thing: bzip archives. Are the reasons for use of hardlinks/symlinks in this particular case purely historical or am I missing something?
Clarification of my question:
I'm not asking about:
- The technical differences between symlinks and hardlinks
- The theoretical advantages and disadvantages each of them
These questions have been addressed in other threads on SO.
I'm trying to understand why different decisions were made in a specific case: for a group of related system utilities. Technically, they all could've been symlinks or they all could've been hardlinks, both options would work (and in both cases a program can still figure out how it's been invoked via argv[0]). I want to understand the intent here if there is any.
Related:
/binthe third column ofls -laiis always1so it seems to only use soft links. What distro do you use? – replay Sep 25 '13 at 08:56