The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
using find to locate hard and soft links with tar manthasirisha Shell Programming and Scripting 4 03-14-2006 03:57 PM
Ignoring symbolic/hard links while scanning through a directory Yifan_Guo High Level Programming 4 03-11-2005 06:38 PM
cp a dty without symbolic links? JAKEZ SUN Solaris 7 09-21-2004 01:55 PM
links.... soft or hard.. not sure? yls177 UNIX for Dummies Questions & Answers 5 10-25-2002 04:12 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-07-2002
gusla gusla is offline
Registered User
  
 

Join Date: Feb 2002
Posts: 31
Unhappy links: (soft, hard? symbolic??) inode

Hi,

what is link? and soft link? how about hard one and symbolic link.
and inode.

i get confuse about this links. could anyone help me with full explainsion?

thks

Gusla
  #2 (permalink)  
Old 05-07-2002
killerserv's Avatar
killerserv killerserv is offline Forum Advisor  
Unix Predator
  
 

Join Date: Dec 2000
Location: Phoenix, AZ
Posts: 670
A link is a pointer to another file. A directory is nothing more than a list of the names and i-numbers of files. A directory entry can be a hard link, in which the i-number points directly to another file. A hard link to a file is indistinguishable from the file itself. When a hard link is made, then the i-numbers of two different directory file entries point to the same inode. For that reason, hard links cannot span across file systems. A soft link (or symbolic link) provides an indirect pointer to a file. A soft link is implemented as a directory file entry containing a pathname. Soft links are distinguishable from files, and can span across file systems. Not all versions of UNIX support soft links.

Filesystem(symbolic link, soft link, hard link, shortcut, alias) is a special type of Unix file which refers to another file by its pathname. A symbolic link is created with the "ln" (link) command:

Code:
ln -s OLDNAME NEWNAME

Where OLDNAME is the target of the link (usually a pathname) and NEWNAME is the pathname of the link itself.
Most operations (open, read, write) on the symbolic link automatically diference it and operate on its target (OLDNAME). Some operations (e.g. removing) work on the link itself (NEWNAME).

In contrast with hard links, there are no restrictions on where a symbolic link can point, it can refer to a file on another file system, to itself or to a file which does not even exist (e.g. when the target of the symlink is removed). Such problems will only be detected when the link is accessed.
  #3 (permalink)  
Old 05-07-2002
hugo_perez hugo_perez is offline
Registered User
  
 

Join Date: Apr 2002
Location: Argentine - that better than to eat meat and to drink wine (both Argentineans)?.
Posts: 132
You have an explanation about hard links and soft links wiyh directories.

An explanation with files could be:

A file is referenced in the system by a i-node number, when you create a
file, the OS assign an i-node number to the file_name.
example:

a- create a file "pp"
echo "hard_soft_link_inode?" >> pp

b- list the file
ls -l pp
-rw-r--r-- 1 root system 22 May 07 18:39 pp
The number 1 is the number of hard links that the file has.

c- view the i-node number of pp assigned by the system:
ls -i pp
24 pp
the 24 number is the i-node number


d- when you make a hard link, the count of i-nodes of the file
is increased by 1 (and when you unlink the the hard link the number
is decreased by 1):

ln pp hard_link_to_pp
ln pp hard_link2_to_pp
ls -l pp
-rw-r--r-- 3 root system 22 May 07 18:39 pp

ls -i hard_link_to_pp
24 hard_link_to_pp

ls -i hard_link2_to_pp
24 hard_link_to_pp


if you remove the original file (you can access the file content by the
hard link)
rm pp

cat hard_link_to_pp
hard_soft_link_inode?

when you use the unlink command the i-node count decrease by 1:
unlink hard_link_to_pp
ls -l hard_link2_to_pp
-rw-r--r-- 1 root system 22 May 07 18:39 hard_link2_to_pp

if you unlink/rm again you lost the file.

Note: I prefer to use the unlink command over a hard link over the rm command.


The soft link is a pointer that could be point to nothing, to a file in the
same FS, or to a file in other FS (recommended use). To create a soft link
you need to use the "-s" flag of the "ln command".

A common use of hard links is some scripts in the rcX.d (X=1,2,3,S) that
are associated to files in the init.d directory. Use the "ls -i" in rc3.d and in the
init.d directories.

Good luck with your test, and sorry with my poor english.
  #4 (permalink)  
Old 05-09-2002
gusla gusla is offline
Registered User
  
 

Join Date: Feb 2002
Posts: 31
Wink how to find out the files have the same inode number? and ..

thank you guys for taking time typing the stuff. it's been really helpful.

how to find out the files have the same inode number? and, is it easy to find out who has access to my files?

thks
  #5 (permalink)  
Old 05-09-2002
killerserv's Avatar
killerserv killerserv is offline Forum Advisor  
Unix Predator
  
 

Join Date: Dec 2000
Location: Phoenix, AZ
Posts: 670
you may use ls -i -a or ls -i command
-i represents the inode for a file system.
  #6 (permalink)  
Old 05-09-2002
hugo_perez hugo_perez is offline
Registered User
  
 

Join Date: Apr 2002
Location: Argentine - that better than to eat meat and to drink wine (both Argentineans)?.
Posts: 132
a-
ls -iR |sort > inum_of_files.txt
more inum_of_files.txt

b- for a specific file, take the i-node number with ls -i and then:

find / -inum <i-node_number> -ls
(example for AIX)

Good luck. Hugo.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0