<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: hard link in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833132#M779073</link>
    <description>Hi shiv, no problem. your interest to learn is interesting. &lt;BR /&gt;&lt;BR /&gt;The idea is commands can have different names(with the help of alias command). in the same way to give different names to files, they found link(ln) command.&lt;BR /&gt;&lt;BR /&gt;but there are 2 limitations with hard links:&lt;BR /&gt;1. hard links cannot cross file systems.&lt;BR /&gt;2. hard links cannot link directories.&lt;BR /&gt;&lt;BR /&gt;to make it possible, they found soft links.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;wikipedia:&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/Ln_%28Unix%29" target="_blank"&gt;http://en.wikipedia.org/wiki/Ln_%28Unix%29&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 28 Jul 2006 23:54:33 GMT</pubDate>
    <dc:creator>inventsekar_1</dc:creator>
    <dc:date>2006-07-28T23:54:33Z</dc:date>
    <item>
      <title>hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833124#M779065</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I understand the use and signifincance of soft link which is created using "$ln -s"  command.&lt;BR /&gt;&lt;BR /&gt;But can't undertsand why we need to create hard link ?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Shiv&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 17:09:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833124#M779065</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-07-28T17:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833125#M779066</link>
      <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;Hard links provide alternative names by which to access an object (file), just as symbolic (soft) links do.&lt;BR /&gt;&lt;BR /&gt;Hard links, however, point directly to their reference (e.g. file) whereas symbolic (soft) links constitute a name (path) that must be followed to eventually find the object of reference.&lt;BR /&gt;&lt;BR /&gt;As such, then, hard links are faster than soft links.&lt;BR /&gt;&lt;BR /&gt;A disadvantage of a hard link, however, is that it cannot point across filesystems whereas a symbolic (soft) link can.  Remember that hard linked files all share a common inode number as exposed by 'ls -il'.  Inode numbers are *only* unique within a filesystem.  That is, inode #101 can exist in multiple filesystems (mountpoints) but point to wholly different files (or directories).  THus, hard links cannot point across filesystems.  &lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 28 Jul 2006 17:56:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833125#M779066</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-28T17:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833126#M779067</link>
      <description>and hard links are the traditional UNIX links. They have always been a part of UNIX from its original inception --- unlike symbolic links which came along later to solve the problem of creating links which could span filesystems. hard links are simply multiple directory entries which share a common inode and you are much more familiar with them than you know. For examle the "." and ".." directory names are hard links.</description>
      <pubDate>Fri, 28 Jul 2006 18:56:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833126#M779067</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-28T18:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833127#M779068</link>
      <description>and hard links are the traditional UNIX links. They have always been a part of UNIX from its original inception --- unlike symbolic links which came along later to solve the problem of creating links which could span filesystems. hard links are simply multiple directory entries which share a common inode and you are much more familiar with them than you know. For example the "." and ".." directory names are hard links.</description>
      <pubDate>Fri, 28 Jul 2006 18:56:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833127#M779068</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-28T18:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833128#M779069</link>
      <description>What are the other files or directories which are the examples of hard links ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shiv</description>
      <pubDate>Fri, 28 Jul 2006 19:29:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833128#M779069</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-07-28T19:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833129#M779070</link>
      <description>You need to learn to start asking the box itself questions like that:&lt;BR /&gt;&lt;BR /&gt;Look for any regular files that have more than 1 link or directories that have more than 2 (all directories will have at least its own name plus ".").&lt;BR /&gt;&lt;BR /&gt;find . -type f -links +1 # regular files with more than 1 link&lt;BR /&gt;&lt;BR /&gt;find . -type d -links +2 # directories with more than 2 links&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 22:57:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833129#M779070</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-28T22:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833130#M779071</link>
      <description>I apologize with gurus for asking simple questions. Unfortunately, i have very primitive knowledgebase in Unix. I worked for many years on other flavors Unix though. But it seems i have learned and used few commands repeatedly for many years.&lt;BR /&gt;I never got opportunity to work in the team of unix sys admins. &lt;BR /&gt;&lt;BR /&gt;I am grateful to gurus and other experts who are sharing their knowledge.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shiv</description>
      <pubDate>Fri, 28 Jul 2006 23:15:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833130#M779071</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-07-28T23:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833131#M779072</link>
      <description>Hi Shiv,&lt;BR /&gt;&lt;BR /&gt;From the ln man pages:&lt;BR /&gt;----------------------------------------------------------------------&lt;BR /&gt;Hard links are created with the same ownerships and permissions as the&lt;BR /&gt;      file or directory to which they are linked.  If ownership or&lt;BR /&gt;      permissions are changed on a link or file, the same changes appear on&lt;BR /&gt;      corresponding hard links.  The ln command does not permit hard links&lt;BR /&gt;      to a directory.&lt;BR /&gt;&lt;BR /&gt;      Symbolic links are created with the ownership of the creator and the&lt;BR /&gt;      permissions are of the creator's current umask.  Once created, the&lt;BR /&gt;      symbolic link ownership and permissions will not change, since the&lt;BR /&gt;      mode and ownership of the symbolic link is ignored by the system.&lt;BR /&gt;----------------------------------------------------------------------&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 23:33:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833131#M779072</guid>
      <dc:creator>inventsekar_1</dc:creator>
      <dc:date>2006-07-28T23:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833132#M779073</link>
      <description>Hi shiv, no problem. your interest to learn is interesting. &lt;BR /&gt;&lt;BR /&gt;The idea is commands can have different names(with the help of alias command). in the same way to give different names to files, they found link(ln) command.&lt;BR /&gt;&lt;BR /&gt;but there are 2 limitations with hard links:&lt;BR /&gt;1. hard links cannot cross file systems.&lt;BR /&gt;2. hard links cannot link directories.&lt;BR /&gt;&lt;BR /&gt;to make it possible, they found soft links.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;wikipedia:&lt;BR /&gt;&lt;A href="http://en.wikipedia.org/wiki/Ln_%28Unix%29" target="_blank"&gt;http://en.wikipedia.org/wiki/Ln_%28Unix%29&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 28 Jul 2006 23:54:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833132#M779073</guid>
      <dc:creator>inventsekar_1</dc:creator>
      <dc:date>2006-07-28T23:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833133#M779074</link>
      <description>Hi Shiv:&lt;BR /&gt;&lt;BR /&gt;One of the most dramatic examples of hard linked files on HP-UX can be found with the LVM binaries.&lt;BR /&gt;&lt;BR /&gt;For instance, at the shell prompt if you do:&lt;BR /&gt;&lt;BR /&gt;# ls -il /sbin/v*&lt;BR /&gt;&lt;BR /&gt;...you will see that many of the LVM commands share a common binary.  At runtime, the *name* of the invoked command can be examined by the binary code to determine what function to perform.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 29 Jul 2006 06:46:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833133#M779074</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-29T06:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833134#M779075</link>
      <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;As a further exercise for you, note the inode number from the output of:&lt;BR /&gt;&lt;BR /&gt;# ls -il /sbin/vgdisplay&lt;BR /&gt;&lt;BR /&gt;You will see something like:&lt;BR /&gt;&lt;BR /&gt;3641 -r-sr-xr-x  31 root sys ...&lt;BR /&gt; &lt;BR /&gt;On one of my systems, that means that inode #3641 belongs to '/sbin/vgdisplay', and there are thirty-one (31) hard links represented by this inode.&lt;BR /&gt;&lt;BR /&gt;Now, using that number (nnnn) as the argument to '-inum' as:&lt;BR /&gt;&lt;BR /&gt;# find /sbin -xdev -inum nnnn &lt;BR /&gt;&lt;BR /&gt;...you should find the thirty-one variations of this binary.&lt;BR /&gt;&lt;BR /&gt;To reinforce (again) that an inode value is only unique within a filesystem, I added the '-xdev' option to the 'find' arguments to prevent traversing mountpoints.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 29 Jul 2006 09:23:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833134#M779075</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-29T09:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833135#M779076</link>
      <description>--- and now for the rest of the story about an executable file having multiple links to a common inode, my favorite example is "sh".&lt;BR /&gt;Do an "ls -i /usr/bin/sh /usr/bin/rsh" and you will find that both of these point to a common inode --- they are thus hard-linked.&lt;BR /&gt;Now ask yourself, how does this executable file know how to behave as either the normal shell (sh) or the restricted shell (rsh)?  --- and remember, there is but one actual executable file. If you do a cksum of /usr/bin/sh and /usr/bin/rsh, you will get exactly the same result.&lt;BR /&gt;&lt;BR /&gt;Understanding how this occurs lies at the heart of every executable spawned by the system. Every program has a main that looks like this:&lt;BR /&gt;&lt;BR /&gt;int main(int argc; char *argv[])&lt;BR /&gt;&lt;BR /&gt;argc =&amp;gt; the number of arguments passed on the command line; always at least 1 because argv[0] contains the name of the executable.&lt;BR /&gt;argv[] is an array of strings that are the arguments.&lt;BR /&gt;&lt;BR /&gt;So the shell program tests to see if argv[0] is "sh" or "rsh" and thus determines its behavior.&lt;BR /&gt;&lt;BR /&gt;Additional Note for more interested students: There is actually a 3rd argument passed to the newly exec()'ed process and that is char **envp; This is a NULL terminated array of pointers containing the environment variables.&lt;BR /&gt;&lt;BR /&gt;------------------------------------&lt;BR /&gt;&lt;BR /&gt;Little gems of knowledge like this are why I think every UNIX admin should at least know some C or C++ because it leads to a much better grasp of how things work (and why they might not be working).</description>
      <pubDate>Sat, 29 Jul 2006 19:39:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833135#M779076</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-29T19:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833136#M779077</link>
      <description>Hi Clay and James,&lt;BR /&gt;&lt;BR /&gt;In the below output:&lt;BR /&gt;&lt;BR /&gt;# ls -il /sbin/vgdisplay&lt;BR /&gt;&lt;BR /&gt;You will see something like:&lt;BR /&gt;&lt;BR /&gt;3641 -r-sr-xr-x 31 root sys ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If there are so many (31 in this case) files (binary) are pointing towards the same inode then does it mean that hard link concept was designed to accomodate large number of files in superblock ? May be superblock has some limitaton on storing the inode numbers ??&lt;BR /&gt;&lt;BR /&gt;warm regards,&lt;BR /&gt;Shiv</description>
      <pubDate>Sat, 29 Jul 2006 21:42:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833136#M779077</guid>
      <dc:creator>Shivkumar</dc:creator>
      <dc:date>2006-07-29T21:42:22Z</dc:date>
    </item>
    <item>
      <title>Re: hard link</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833137#M779078</link>
      <description>Hi (again) Shiv:&lt;BR /&gt;&lt;BR /&gt;Filenames point to inodes in the Unix filesystem.  The inode holds the metadata associated with the file that points to it.  That is, the inode constains things like the file's size, modification time, access time, owner (uid), permissions, etc.  Look at the manpages for 'stat(2)' since this describes the system call by which these data are retrieved.&lt;BR /&gt;&lt;BR /&gt;Given that a file*name* points to an inode, the *name* really can be said to be the hard link.  The number times different file (names) point to the same inode is maintained as the link count, 'st_nlink'.&lt;BR /&gt;&lt;BR /&gt;Further, from the 'stat(2)' manpages we can see that the link count is an unsigned short integer, so we can have counts up to 65,535 stored!&lt;BR /&gt;&lt;BR /&gt;When the link count is zero, a file is deleted, *unless* it is open by a process.   Indeed, it is a common practice to create (open) a temporary file in a program and immediately 'unlink(2)' it.  This means that only the owning process can access the file.  At process termination, the file and any allocated space vanish.  The downside&lt;BR /&gt;is that it is more difficult to find who or what is consuming space in a filesystem when something goes wrong.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sun, 30 Jul 2006 11:05:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/hard-link/m-p/3833137#M779078</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-30T11:05:57Z</dc:date>
    </item>
  </channel>
</rss>

