红联Linux门户
Linux帮助

What's the hard link and soft link

发布时间:2008-07-29 16:14:33来源:红联作者:ykde
In Linux it is possible to give more than one name to a file by

creating links. Notice that Creating a link to a file is not the

same as creating a copy of the file! Links are divided to

hard and soft ones.

They can be used for different purposes and they have diffenet

characteristics and functionalities.

The general way for creating a hard link is the following:

ln file_name link_name

Like:

ln mymemo mymemo_link

You can check the number of hard links to a file or directory by

using ls -l command with the name of the file. For

example, if I have a file called view.gif and use ls -l

to check its information, I'll see an output like the following:

Wed Nov 10-->ls -l view.gif

-rw-r--r-- 1 mg users 0 Nov 10 11:50 view.gif

Number 1 in the secnd column tells us that there is only one hard

link, which refers to the physical content of the file on the drive. But

after we create another name for the file by making a hard link to it

in the following way:

ln view.gif viewln.gif

If we use ls -l command to check the file information

again,

we will see the following output:

Wed Nov 10-->ls -l view.gif

-rw-r--r-- 2 mg users 0 Nov 10 11:50 view.gif

Now, number 2 in the second column suggets that there are two

names, i.e. two hard links referring to the same physical contents.

The general way for creating a soft link is the following:

ln -s file_name link_name

Like:

ln -s view.gif view_slink.gif
文章评论

共有 0 条评论