Results 1 to 5 of 5
Hi,
I was trying to create a soft link to a directory with link. It said operation not permitted. But it worked with ln command. I checked out the man ...
- 03-20-2007 #1Just Joined!
- Join Date
- Feb 2005
- Location
- India
- Posts
- 24
link and ln
Hi,
I was trying to create a soft link to a directory with link. It said operation not permitted. But it worked with ln command. I checked out the man pages and it said "call the link function to create a link to a file" for both commands. What is the difference?
P.S.: Don't know whether its rite to post this query in programming section.. but cudn't see where it fits rite. Please excuse.
Thanx.
- 03-20-2007 #2
Did u use -s option with ln?
Basically link creates hard links. ln, by defualt (without any options) too creates hard links. But if you use -s option, then it is a soft link.---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------
- 03-21-2007 #3Just Joined!
- Join Date
- Feb 2005
- Location
- India
- Posts
- 24
Hi cyberinstru,
Creating a soft/hard link isn't my problem. I read the man page for ln and cud create a link. My doubt is why "link" command failed me when "ln" internally makes the same system call "link()".
Mebe I wasn't clear enuf in my previous post. I'll elaborate a bit.
I wanted to make a soft link to a directory (not a file). I used the link command. But it gave an error, operation not permitted. Then I looked up on the net and saw that the correct command in this case wud be ln -s. So I used that and my job was done. Later I compared both the man pages. U know that short one-line description given at the start of the man page - it said similar thing for both the commands (link & ln).
link - "call the link function to create a link to a file"
ln - "make links between files"
I just wanna know why link failed me where ln worked. What difference is there??
Hope I've cleared out any ambiguity
- 03-21-2007 #4
ln and link are not same commands.
Link supports Files only. you can't link directories with link command. please check man pages of both commands again.It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 03-21-2007 #5Basically you have two links.I wanted to make a soft link to a directory (not a file). I used the link command. But it gave an error, operation not permitted. Then I looked up on the net and saw that the correct command in this case wud be ln -s. So I used that and my job was done. Later I compared both the man pages. U know that short one-line description given at the start of the man page - it said similar thing for both the commands (link & ln).
link - "call the link function to create a link to a file"
ln - "make links between files"
I just wanna know why link failed me where ln worked. What difference is there??
1. Hard links
2. Soft links or Symbolic links
Hard links cannot be used for directories. Also, hards links cannot be used for files in different mounts. Only kernel can create a hard link to directories. User cannot do.
You would have seen one single dot '.' and a double dot '..' in every directory. These are nothing but hard links. Hard links have same inodes as that of the original file.
Soft links have different inodes. i.e. a new inode data is created when u create a soft links. This is the reason that u can create soft links for directories and for files in different mounts.
For ex:
Create a file: test.txt
Create a soft link: ln -s test.txt sltest.txt
Create a hard link: ln test.txt hltest.txt
now see the inodes of these files:
ls -il *test.txt
Output:
the inodes for the file and itz hard link are same.2060644 -rw-r--r-- 2 aruns users 0 Mar 21 13:38 hltest.txt
2060646 lrwxrwxrwx 1 aruns users 8 Mar 21 13:38 sltest.txt -> test.txt
2060644 -rw-r--r-- 2 aruns users 0 Mar 21 13:38 test.txt
This is the major difference b/w soft link and a hard link.
link and ln (without -s option) are same. Bot creates hard links.
ln with -s option creates soft link.
Since soft links create a new inode, it takes more space that that is occupied by a hard link.
Hope this helps.---------------------------------
Registered Linux User #440311
HI2ARUN _AT_ GMAIL _DOT_ COM
---------------------------------


Reply With Quote