Hard Links and Soft or Sym links

When loooking at files in a directory using ls, how can I tell if I have a hard link or soft link?

Finding Soft Link

lr--r--r-- --> if it starts with l (then it means soft link)

To create soft link

ln -s abc.txt efg.txt

Finding hard link

Hard link shares the same inode.

$ ln abc.txt efg.txt

do ls -li and check the first column value.

both abc.txt and efg.txt have the same value

Thanks for taking the time to answer a very simple question. I did some more reading and I also find that hard links are only on files and not directories. Is that true.

It is indeed true, at least on all file systems Solaris supports.

The "." and ".." special directories originally used to be directory hardlinks (created by hand!) but this hasn't been the case for decades now. This discussion's come up a few times, and nobody's managed to find a modern OS that supports directory hardlinks so far.

I shudder to think that a file system would risk the real possibility of recursion when directories are hard linked.

Maybe a wee bit off topic, but maybe not, Rob Pike (Bell Labs then, now at Google) wrote an interesting paper on getting '..' right after the introduction of symbolic (soft) links:

Lexical File Names in Plan 9 or Getting Dot-Dot Right

Certainly an interesting read.

Linux supports mount --bind originaldir newdir, which makes the contents from originaldir also appear in newdir without the pathing ambiguity a symlink makes. (And adding a totally new kind of ambiguity, heh -- the files now have two equally valid paths.)

which might have been inspired by Solaris lofs , released about years earlier:

mount -F lofs originaldir newdir

why do need to use the hard link from the beginig can pleas help me i am learning unix by my self so i do not know why do need the hard link or soft link

what if i donot link the file

any problem

thank you

If you have hard link inside some directory and then you make some changes on file created with hard link than that file won't be affected because they don't share common address space so there is no sync between that two file. If you create file with symbolic link and the edit file cretaed with symbolic link original file on which that link points will be changed. If you delete symbolic link original file won't be deleted but if you delete original file than a symbolic link is also deleted because they share common virtual address space and sync is possible between that two files.

You don't need to use (multiple) hard links or soft links. They are sometimes a very useful facility but you can live without them.

when they will be use full

---------- Post updated at 02:14 AM ---------- Previous update was at 02:11 AM ----------

so you mean to say if i want to create a to a file then i want to change one and keep another as it is then i can use it

as a backup or some thing like that
pleas explain more about the concept it self

thank you dear