LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 12-11-2007, 08:21 AM   #1
bzlaskar
Member
 
Registered: May 2006
Location: Bangalore, INDIA
Distribution: Fedora Core
Posts: 69
Blog Entries: 2

Rep: Reputation: 17
how to distinguish between a original file and a hard link


Greetings,

I have created a hard between two files on the same file system
with the command

ln mysqlaccess.log mysqlaccess

But is there is any to distinguish which is the original file
and which one is the link.

Both `ls -l ` and `stat ` on the two files showing the same content.

$ ls -lH mysqlaccess*

-rw-r--r-- 2 root root 14 Dec 11 19:18 mysqlaccess
-rw-r--r-- 2 root root 14 Dec 11 19:18 mysqlaccess.log

[root@gdrd5 ~]# stat mysqlaccess*
File: `mysqlaccess'
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 900h/2304d Inode: 641593 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2007-12-11 19:18:41.000000000 +0530
Modify: 2007-12-11 19:18:41.000000000 +0530
Change: 2007-12-11 19:18:41.000000000 +0530
File: `mysqlaccess.log'
Size: 14 Blocks: 8 IO Block: 4096 regular file
Device: 900h/2304d Inode: 641593 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2007-12-11 19:18:41.000000000 +0530
Modify: 2007-12-11 19:18:41.000000000 +0530
Change: 2007-12-11 19:18:41.000000000 +0530


With thanks in Advance

regards
zaman
 
Old 12-11-2007, 08:45 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
As far as I know, you can't. Hard links share the same data with different names in different locations (on the same disk) but they are truly un-distinguishable... except for their path!
 
Old 12-11-2007, 08:58 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
A hard link is simply another name for the same file info. (In your stat results note that the inode #s are the same.) You can create a hard link and then delete the original. The data will still be there as long as it has at least one link (filename).

http://www.askdavetaylor.com/how_do_...inks_work.html

With a soft link, if you delete the original, the data is gone. (The link will still be there, but go nowhere.)
 
  


Reply



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
how do I know if a file has a hard link to it? granny Linux - Newbie 13 04-04-2015 05:02 AM
Difference Between Soft Link & Hard Link rajaniyer123 Solaris / OpenSolaris 16 09-30-2012 03:42 AM
Moving linux partition from original hard drive to another, howto??? Fear58 Linux - General 22 02-15-2008 04:26 PM
unzip and keep original file ? Blaumieser Linux - Newbie 5 09-21-2005 03:24 PM
how to distinguish a file and a directory joeyBig Programming 2 10-01-2004 04:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:08 PM.

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
Open Source Consulting | Domain Registration