LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-23-2011, 12:00 PM   #1
drManhattan
Member
 
Registered: Aug 2010
Location: Warsaw, Poland
Distribution: Ubuntu 10.04 LTS on IBM Lenovo R61e, RHEL5-6,SLES10-11
Posts: 262

Rep: Reputation: 1
hard links why to use


Hi

I wonder what is the purpose of using hard links instead of being a shortcut to some file ?

thx for help.
 
Old 03-23-2011, 12:14 PM   #2
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 195

Rep: Reputation: 50
A hard link is second filename referencing the same inode (file).

A symbolic link is a shortcut or redirect from one inode to the original.

For this reason hard links MUST be in the same filesystem, soft/sym links can be in different filesystems.


Read more details below, it is a lot to type.

http://www.linuxclues.com/articles/17.htm

http://linuxgazette.net/105/pitcher.html
 
Old 03-23-2011, 12:38 PM   #3
drManhattan
Member
 
Registered: Aug 2010
Location: Warsaw, Poland
Distribution: Ubuntu 10.04 LTS on IBM Lenovo R61e, RHEL5-6,SLES10-11
Posts: 262

Original Poster
Rep: Reputation: 1
I understand the differences but what I don't understand is when each link is used ?
In which circumstances sys admins use symbolic links and in which hard links ?

thx for help.
 
Old 03-23-2011, 12:44 PM   #4
savona
Member
 
Registered: Mar 2011
Location: Bellmawr, NJ
Distribution: Red Hat / Fedora
Posts: 195

Rep: Reputation: 50
Quote:
Originally Posted by drManhattan View Post
I understand the differences but what I don't understand is when each link is used ?
In which circumstances sys admins use symbolic links and in which hard links ?

thx for help.
Well I personally almost always use sym links. But...

1) Hardlinks are faster (small bit)
2) One hardlink can be deleted but the data still exists. If you delete the data from a sym link you have garbage in the link.


I dont know of any other reasons, like I said I almost always use sym links. But I could see why some people say ALWAYS use hard links if your in the same filesystem. I guess its another one of my bad habits.
 
Old 03-23-2011, 01:04 PM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 3,774
Blog Entries: 1

Rep: Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339Reputation: 1339
Quote:
Originally Posted by drManhattan View Post
I understand the differences but what I don't understand is when each link is used ?
In which circumstances sys admins use symbolic links and in which hard links ?

thx for help.
Hardlinks are faster(1 cpu cycle faster )

Hardlinks are,.. sort of inheriting. As in:

If you have a file and you hardlink to it, then delete the file, the hardlink will now be the file.

Symlinks are the opposite of that. If you delete the original file that the symlink points to, you have a meaningless symlink.

As far as when to use hardlinks? If you are using links accross disks/filesystems, then you have to use a Symlink. There are certain situations where you can use hardlinks as a backup: like this http://slaptijack.com/system-adminis...th-hard-links/

Hope this helps.
 
Old 03-23-2011, 02:02 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Two uses of hard links:
  • Hard links allow a single executable to have more than one name; when it is called it can check the name it was called by and behave differently. This is useful when a lot of the code is common. Can be used for binaries and scripts.
  • Hard links allow a single file to be accessed by several paths. This is useful to reduce data volume (not often but it can be). I'm currently working on an automated collation of files collected from multiple computers. There are duplicate files. It is not possible for the program to know which directory paths are the most informative so the program keeps them all and hard links allow that to be done with a single copy of each duplicate file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
hard links Ammad Linux - General 4 08-01-2010 02:14 AM
Symbolic links Vs Hard links sulekha Linux - General 2 10-02-2008 08:03 AM
technical question about hard links v soft links 7stud Linux - Newbie 2 02-23-2007 07:57 PM
links (hard links and soft links..) sachitha Programming 1 08-10-2005 01:10 PM
Sym links and hard links akudewan Linux - Newbie 4 02-09-2005 06:08 AM


All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration