LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-14-2004, 11:57 AM   #1
linuxzouk
Member
 
Registered: Apr 2004
Location: Malaysia
Distribution: Fedora Core
Posts: 93

Rep: Reputation: 15
hard link?


# touch a

# ln a b

# ln -s a c

# ll
-rw-r--r-- 2 linuxzouk users 0 May 15 23:53 a
-rw-r--r-- 2 linuxzouk users 0 May 15 23:53 b
lrwxrwxrwx 1 linuxzouk users 1 May 15 23:53 c -> a

# echo "test" > a

# cat a
test

# cat b
test

question.
it seems that hard link is a duplicate. but how would i know that "b" is a link. it's not showing from the command "ll"
 
Old 05-14-2004, 12:24 PM   #2
Ma3oiS
LQ Newbie
 
Registered: May 2004
Posts: 12

Rep: Reputation: 0
hi,

you can know it by I-node number. Try ls -i
Files with the same I-node no. are hardlinks to each other (file in *nix can have many different names but only one I-node).
 
Old 05-14-2004, 12:25 PM   #3
kvedaa
Member
 
Registered: Mar 2004
Location: Virginia
Distribution: PacketProtector
Posts: 331

Rep: Reputation: 30
Well, lets see if I can take a shot at this. A softlink as you have displayed, works kind of like a shortcut does in windows. A hardlink is like giving one file additional names, each hard link to the file creates a name for that file.

One way to determine that the file names are pointing to the same file is by:

ls -il

The 'i' switch will display the inode number, which is the actaul name for the file (the names that we give files are primarly for the benifit of those like myself who can not keep hundreds of 6 diget numbers stright in my head).
 
Old 05-14-2004, 12:29 PM   #4
linuxzouk
Member
 
Registered: Apr 2004
Location: Malaysia
Distribution: Fedora Core
Posts: 93

Original Poster
Rep: Reputation: 15
thanks for replying

if i have many hard links to a single file. how do i search all the hard link's file by inode?
 
Old 05-14-2004, 01:15 PM   #5
kvedaa
Member
 
Registered: Mar 2004
Location: Virginia
Distribution: PacketProtector
Posts: 331

Rep: Reputation: 30
If you have a file that you suspect that there is hardlink to on your system, you will first want to get the inode of the file in question by running:

ls -li

remember that traditionally hardlinks need to be on the same drive, so if you are running multiple drives you can save yourself some time and perform the following search only on the drive that the first file is on, but for demonstration purposes we will run the command from root...

find / -inum <inode#>

as with most finds if you can limit your search area you will often have a quicker result, but this should give you a list of all names for the file in question.
 
Old 05-15-2004, 01:20 AM   #6
linuxzouk
Member
 
Registered: Apr 2004
Location: Malaysia
Distribution: Fedora Core
Posts: 93

Original Poster
Rep: Reputation: 15
thanks for your detail reply
 
  


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
how do I know if a file has a hard link to it? granny Linux - Newbie 13 04-04-2015 06:02 AM
how to remove a hard link... trey85stang Linux - Newbie 17 07-14-2008 01:17 PM
cp: will not create hard link ????? taiwf Linux - Newbie 3 09-20-2005 07:56 PM
hard link not working ghee22 Linux - General 5 08-31-2005 01:46 PM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 07:30 AM


All times are GMT -5. The time now is 04:04 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration