Just curious: why is /usr/bin/python not a symlink?

H

HoneyMonster

$ cd /usr/bin
$ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
$ diff -s python python2.7
Files python and python2.7 are identical
$

I'm just curious: Why two identical files rather than a symlink?
 
C

Colin Higwell

On Thu, 23 Feb 2012 19:11:16 +0000, HoneyMonster wrote:

(reformatted (I hope)
$ cd /usr/bin
$ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
lrwxrwxrwx 1 root root 6 Oct 29 19:34 python2 -> python
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
$ diff -s python python2.7
Files python and python2.7 are identical
$

I'm just curious: Why two identical files rather than a symlink?

Sorry, my first post didn't format properly.
 
J

Jerry Hill

$ cd /usr/bin
$ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
lrwxrwxrwx 1 root root    6 Oct 29 19:34 python2 -> python
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
$ diff -s  python python2.7
Files python and python2.7 are identical
$

I'm just curious: Why two identical files rather than a symlink?

It's not two files, it's a hardlink. You can confirm by running ls
-li python* and comparing the inode numbers.
 
C

Chris Rebert

$ cd /usr/bin
$ ls -l python*
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python
lrwxrwxrwx 1 root root    6 Oct 29 19:34 python2 -> python
-rwxr-xr-x 2 root root 9496 Oct 27 02:42 python2.7
$ diff -s  python python2.7
Files python and python2.7 are identical
$

I'm just curious: Why two identical files rather than a symlink?

Depends on your distro / installation method:
$ ls -l python*
lrwxrwxrwx 1 root root 9 Apr 12 2011 python -> python2.6
-rwxr-xr-x 1 root root 2288272 Dec 27 2010 python2.6
$ # this is on my Debian server

Cheers,
Chris
 
H

HoneyMonster

It's not two files, it's a hardlink. You can confirm by running ls -li
python* and comparing the inode numbers.

You are spot on. Thank you, and sorry for my stupidity.
 
J

Jerry Hill

You are spot on. Thank you, and sorry for my stupidity.

I don't think you're stupid. It's hard to tell the difference between
two separate files with the same file size and a hardlink. The
biggest clue is the number "2" in the second column. If I recall
correctly, for directories, that's the number of entries in the
directory. For files, that number is the number of hardlinks
referring to that file.

Even with that, it's hard to tell what files are hardlinked together,
and figuring it out by inode is a pain in the neck. Personally, I
prefer symlinks, even if they introduce a small performance hit.
Readability counts, even in the filesystem.
 
T

Terry Reedy

You are spot on. Thank you, and sorry for my stupidity.

The question 'why a hardlink rather than symlink' is not stupid. It was
part of the discussion of http://python.org/dev/peps/pep-0394/
The answer was 'history' and how things were 20 years ago and either the
pep or the discussion around it says symlinks are fine now and the
decision is up to distributors.
 
T

Thomas Rachel

Am 23.02.2012 20:54 schrieb Jerry Hill:
If I recall
correctly, for directories, that's the number of entries in the
directory.

No. It is the number of subdirectories (it counts their ".." entries)
plus 2 (the parent directory and the own "." entry).

Even with that, it's hard to tell what files are hardlinked together,
and figuring it out by inode is a pain in the neck. Personally, I
prefer symlinks, even if they introduce a small performance hit.

Not only that, they have slightly different semantics. With hardlinks
you can say "I want this file, no matter if someone else holds it as
well". Symlinks say "I want the file which is referred to by there".

In the given case, however, this difference doesn't count, and I agree
on you that a symlink would be better here.


Thomas
 
R

Roy Smith

Thomas Rachel
Not only that, [hard and symbolic links] have slightly different
semantics.

This is true, but only for very large values of "slightly".

Symlinks, for example, can cross file system boundaries (including NFS
mount points). Symlinks can refer to locations that don't exist! For
example:

~$ ln -s foobar foo
~$ ls -l foo
lrwxr-xr-x 1 roy staff 6 Feb 24 08:15 foo -> foobar
~$ cat foo
cat: foo: No such file or directory

Symlinks can be chained (i.e. a symlink points to someplace which in
turn is another symlink). They're really very different beasts.
 
J

John Roth

The question 'why a hardlink rather than symlink' is not stupid. It was
part of the discussion ofhttp://python.org/dev/peps/pep-0394/
The answer was 'history' and how things were 20 years ago and either the
pep or the discussion around it says symlinks are fine now and the
decision is up to distributors.

I believe the changes for PEP 394 are using symlinks. The distro
maintainer can, of course, change that.

John Roth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top