LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 12-16-2002, 02:00 PM   #1
Ciccio
Member
 
Registered: Nov 2002
Location: Paraguay
Distribution: Mandrake 10
Posts: 573

Rep: Reputation: 30
Symbolic and hard links


I would like to know a few things about these two issues. What are symbolic and what are hard links? What is the difference between them? what happends when I delet a symbolic link and what happends when I delet a hard link? What is the sixe of each and why is this size different?

Could anyone recomend me a good paper or answer these questions for me please. Thank you very much, in advance.

LiNuZ FReaKY -=WiReLeSS VeRSioN=-
 
Old 12-16-2002, 02:10 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 197Reputation: 197
From the MAN page:

A hard link is just a name for a file. (And a file can have several names. It is deleted from disk only when the last name is removed. The number of names is given by ls(1). There is no such thing as an `original' name: all names have the same status. Usually, but not nec-essarily, all names of a file are found in the filesystem that also contains its data.)

A soft link (or symbolic link, or symlink) is an entirely different animal: it is a small special file that contains a pathname. Thus, soft links can point at files on different filesystems (possibly NFS mounted from different machines), and need not point to actually existing files. When accessed (with the open(2) or stat(2) system calls), a reference to a symlink is replaced by the operating system kernel with a reference to the file named by the path name. (However, with rm(1) and unlink(2) the link itself is removed, not the file it points to. There are special system calls lstat(2) and readlink(2) that read the status of a symlink and the filename it points to. For various other system calls there is some uncertainty and variation between operating systems as to whether the operation acts on the symlink itself, or on the file pointed to.)

In a more easier way to understand:

Soft links

Pointers to programs, files, or directories located elsewhere (just like Windows shortcuts)
If the original program, file, or directory is renamed, moved, or deleted, the soft link is broken.
If you type ls -F you can see which files are soft links because they end with @
To create a soft link called myfilelink.txt that points to a file called myfile.txt, use this:
ln -s myfile.txt myfilelink.txt

Hard links

Pointers to programs and files, but NOT directories
If the original program or file is renamed, moved, or deleted, the hard link is NOT broken
Hard links cannot span disk drives, so you CANNOT have a hard link on /dev/hdb that refers to a program or file on /dev/hda
To create a hard link called myhardlink.txt that points to a file called myfile.txt, use this:
ln myfile.txt myhardlink.txt
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
symbolic links durden2.0 Linux - Newbie 6 11-12-2008 03:06 AM
Symbolic Links Greg_courageous Linux - Newbie 1 05-10-2004 07:05 AM
Symbolic links? TongueTied Linux - Newbie 3 08-27-2003 06:00 AM
Symbolic Links petercool Linux - General 2 08-20-2003 11:15 AM
symbolic links winger Linux - General 5 04-06-2002 05:16 PM


All times are GMT -5. The time now is 07:50 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration