Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #162650

Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl]

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl]
Date 2016-01-05 16:30 +0100
Message-ID <qNBIC-4FF-33@gated-at.bofh.it> (permalink)
References (2 earlier) <qNhqx-6E0-1@gated-at.bofh.it> <qNjVp-8lm-23@gated-at.bofh.it> <qNkHM-sc-9@gated-at.bofh.it> <qNlaP-Er-23@gated-at.bofh.it> <qNvjP-7VD-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue 05 Jan 2016 at 09:04:19 (+0100), tomas@tuxteam.de wrote:
> On Mon, Jan 04, 2016 at 04:43:05PM -0500, Gary Dale wrote:
> >          If that is a problem with symlinks, shouldn't it also be with
> > hardlinks?
> 
> No, because of above:
> 
>   - symlink: permissions of linked-to file apply. Symlink has no "own"
>     permissions. When linked-to file is removed, symlink is dangling.
> 
>   - hardlink: each has its own metadata (permissions, etc.). All hardlinks
>     are equivalent. When last link to a file's data is removed, storage
>     is recycled.

That could be interpreted ambiguously. To clarify, the metadata is
stored in the inode, so all the hard links to a particular file/inode
share the same information, thus:

07:45 $ touch foo
07:45 $ ls -li [fb]*
488715 -rw-r----- 1 david david 0 Jan  5 07:45 foo
07:45 $ ln foo bar
07:55 $ ls -li [fb]*
488715 -rw-r----- 2 david david 0 Jan  5 07:45 bar
488715 -rw-r----- 2 david david 0 Jan  5 07:45 foo
07:55 $ chmod a+r bar
07:57 $ ls -li [fb]*
488715 -rw-r--r-- 2 david david 0 Jan  5 07:45 bar
488715 -rw-r--r-- 2 david david 0 Jan  5 07:45 foo
07:57 $ touch bar
07:57 $ ls -li [fb]*
488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 bar
488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 foo
07:57 $ ls -li [fb]*
488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 bar
488715 -rw-r--r-- 2 david david 0 Jan  5 07:57 foo
07:58 $ 

# chown nobody /tmp/bar

07:58 $ ls -li [fb]*
488715 -rw-r--r-- 2 nobody david 0 Jan  5 07:57 bar
488715 -rw-r--r-- 2 nobody david 0 Jan  5 07:57 foo
07:59 $ 

Each symlink has its own metadata in its inode, but most of it
is ignored most of the time (eg ownership), or can't be changed
(eg permissions).

> They are different concepts, differently implemented. Functionality is
> somewhat overlapping, that's why in some situations they can be used
> for similar purposes, but for some other things they are radically
> different.

Cheers,
David.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 17:00 +0100
  Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-04 18:20 +0100
    Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 20:10 +0100
      Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 21:00 +0100
        Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-04 21:20 +0100
      Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-04 21:50 +0100
        Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 23:50 +0100
          Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 00:50 +0100
            Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-05 01:30 +0100
              Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 01:40 +0100
  Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 18:20 +0100
    Re: Prevent shutdown with systemctl <tomas@tuxteam.de> - 2016-01-04 18:50 +0100
      Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 21:20 +0100
        Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 21:40 +0100
          Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 22:10 +0100
            Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 22:50 +0100
              Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 01:20 +0100
                Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-05 18:20 +0100
      Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 21:30 +0100
        Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 22:00 +0100
          Re: Prevent shutdown with systemctl David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 05:50 +0100
        Re: Prevent shutdown with systemctl <tomas@tuxteam.de> - 2016-01-04 22:20 +0100
          Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 22:50 +0100
            Re: Prevent shutdown with systemctl David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 06:10 +0100
            Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] <tomas@tuxteam.de> - 2016-01-05 09:40 +0100
              Re: Symlinks vs. hardlinks "Thomas Schmitt" <scdbackup@gmx.net> - 2016-01-05 11:10 +0100
                Re: Symlinks vs. hardlinks <tomas@tuxteam.de> - 2016-01-05 11:40 +0100
              Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] <tomas@tuxteam.de> - 2016-01-05 16:30 +0100
              Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 16:30 +0100
  Re: Prevent shutdown with systemctl Jude DaShiell <jdashiel@panix.com> - 2016-01-04 19:20 +0100
  Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-04 19:30 +0100
    Re: Prevent shutdown with systemctl jdd <jdd@dodin.org> - 2016-01-04 20:10 +0100
      Re: Prevent shutdown with systemctl jdd <jdd@dodin.org> - 2016-01-04 20:30 +0100
      Re: Prevent shutdown with systemctl Chris Bannister <cbannister@slingshot.co.nz> - 2016-01-05 11:10 +0100

csiph-web