<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Tech-Recipes - Latest Comments in Create a hard link in UNIX</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><atom:link href="https://tech-recipes.disqus.com/create_a_hard_link_in_unix_unix_tech_recipes/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Tue, 26 Jul 2011 10:04:00 -0000</lastBuildDate><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-265382206</link><description>&lt;p&gt;Hard links allow a file to exist in several folders while not being duplicated on disk (this is the reason hard links cannot be used across file systems). Actually, one can consider that any file is "hard linked" at least ones, in the folder it has been created. The OS and the applications do not make any distinction between the original location and the "hard linked" ones.&lt;br&gt;E.g. if you store a file in folder A and create a hard link to the file in folder B, the file will be seen by any application as existing at both places (which is not always the case with symbolic links). If you delete the file from folder A, it will still "exist" in folder B, exactly as if it has been created there at the first place. Creating hard links is thus a way to prevent losing data by deleting files by accident.&lt;br&gt;Symbolic links, on the other hand, do not prevent losing data: they are small data structures that contain the path (possibly across file systems) and name of the target file. If the target file is deleted, the data is lost and the symbolic link is "broken".&lt;br&gt;If you want to go deeper, read how inodes are used in Un*x file systems (e.g. see the post from Bastard Operator 468, above, but a few drawings would definitely help).&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bernard Valentin</dc:creator><pubDate>Tue, 26 Jul 2011 10:04:00 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-147125312</link><description>&lt;p&gt;hey plz tell me the advantages of hard link...why is this useful?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">juhi</dc:creator><pubDate>Tue, 15 Feb 2011 02:16:16 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-134757953</link><description>&lt;p&gt;I agree with karelc above.&lt;/p&gt;&lt;p&gt;This is a totally inaccurate article, and douches like you should pick up a linux book and get a hold of your basics, before being allowed to post articles on the web.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">BnB</dc:creator><pubDate>Wed, 26 Jan 2011 06:46:57 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-134757819</link><description>&lt;p&gt;I agree with karelc above.&lt;/p&gt;&lt;p&gt;This is a totally inaccurate title, and douches like you should pick up a linux book and get a hold of your basics, before being allowed to post articles on the web.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">BnB</dc:creator><pubDate>Wed, 26 Jan 2011 06:46:05 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-3431513</link><description>&lt;p&gt;Removing the original file will not destroy the linked file, and therefore the information is not lost. The contents only disappear when all links have been removed&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">karelc</dc:creator><pubDate>Sat, 01 Nov 2008 12:24:15 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-2767073</link><description>&lt;p&gt;I have a hard link in Windows Explorer on XP home edition.  How do I delete it?  (In laymen's terms)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Thu, 24 Mar 2005 07:39:20 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-2767072</link><description>&lt;p&gt;There is another very cool usage of this found at this place : &lt;a href="http://bulma.net/body.phtml?nIdNoticia=2012" rel="nofollow noopener" target="_blank" title="http://bulma.net/body.phtml?nIdNoticia=2012"&gt;http://bulma.net/body.phtml...&lt;/a&gt; . Actually some programs create a different inode from a hardlinked file if you modify the file; for example patch, or vi (if you had previously "set bkc=no") create a new inode when working on these hardlinks. &lt;br&gt;So imagine you are compiling a kernel, trying different patchsets. You dont want to make many "real" copies of the same files, as it takes lot of space and time to do so. Then you could just do hardlinks to the files. And then, only the modified files will actually exist:&lt;/p&gt;&lt;p&gt;cd /usr/src/&lt;br&gt;cp -rl linux-clean linux-experiment&lt;/p&gt;&lt;p&gt;then you will see, the new folder takes lot less space than the original one but is however fully funcional :) you can compile, apply patches, etc....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Sat, 17 Apr 2004 15:05:19 -0000</pubDate></item><item><title>Re: Create a hard link in UNIX</title><link>http://www.tech-recipes.com/rx/173/create-a-hard-link-in-unix/#comment-2767071</link><description>&lt;p&gt;Probably a better way of describing the difference between hard and soft links:&lt;/p&gt;&lt;p&gt;The UNIX file system stores files in inodes.  The filesystem table contains a list of filenames, and the pointer to the inode in which that file exists.&lt;/p&gt;&lt;p&gt;A hard link creates a second entry in the filesystem table pointing to the same inode of the file.  This can be illustrated with the &lt;em&gt;ls&lt;/em&gt; command very easily:&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;br&gt;1: # touch /this&lt;br&gt;2: # ln /this /root/that&lt;br&gt;3: # ls -i /this /root/that&lt;br&gt;4:      18 /root/that       18 /this&lt;br&gt;5: # rm -f /this&lt;br&gt;6: # ls -i /root/that&lt;br&gt;7:      18 /root/that&lt;br&gt;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;What did I do above?  Here's a play-by-play:&lt;/p&gt;&lt;p&gt;1: create a file (/this)&lt;br&gt;2: hardlink the file (/this) to another file (/root/that)&lt;br&gt;3: ask to see the inodes that the files exist in&lt;br&gt;4: note that the inode numbers are identical - 18&lt;br&gt;5: delete the original file&lt;br&gt;6: show me the inode of the other file again&lt;br&gt;7: it's still the same.&lt;/p&gt;&lt;p&gt;In the above example, Inode 18 is occupied only once, and is referenced by two different path/filenames.  Removing the first file doesn't in any way affect the second.  The actual inode is still in use by the second reference.  As soon as you remove all references, the inode is considered unused and can have new data written to it.&lt;/p&gt;&lt;p&gt;One caveat - hard links cannot span mount points.  My own home directory is mounted from another disk, for example, so I cannot hardlink from /this to /home/bofh/that.  The other caveat is that you cannot hard link directories.&lt;/p&gt;&lt;p&gt;Soft links are really pointers to a pointer.  &lt;em&gt;ls -i&lt;/em&gt; on both files will still show they are pointing at the same inode...  but if you remove the original file, then the inode is actually completely dereferenced.  The plus-side is that soft links can span mount points and you can soft link directories.  The downside is that if you remove the original then the link is broken.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">bofh468</dc:creator><pubDate>Thu, 13 Nov 2003 19:27:17 -0000</pubDate></item></channel></rss>