![]() By the way, if you want to see the inode of a file, you can use ls -i hard1.txt.When do you think a hard link might come in handy? What is the use case?.What do you think will happen to the content of the rest of the links? Modify the content of one of the hard links.What is the relationship between anotherhard1.txt and hardy1.txt? Rename hard1.txt to another name, hardy1.txt.What do you expect to happen? What does this tell you about the rm command? (It doesn't really "delete" the file. Create another hard link out of hard1.txt, name it anotherhard1.txt. We've deleted test1.txt but we still have hard1.txt.If you delete the test1.txt burrow, it won't affect hard1.txt at all! The only way to remove it is to completely remove all references to the inode. ![]() If you create a new hard link, you are just creating a third hole to the same, existing burrow. If you remove one hole, the bunny can still go out from the other hole. test1.txt and hard1.txt are the two holes connecting that burrow to the surface. Think of test1 inode like an underground rabbit's burrow. When you ran ln test1.txt hard1.txt, you created a new file name, hard1.txt, connected to the test1 inode. This inode (I'll call it "test1 inode") is connected to a file name test1.txt. When you created test1.txt, you created an inode. Notice that hard1.txt is still there and the text inside hasn't changed. Inside it, add some texts:Įnter fullscreen mode Exit fullscreen mode That file that you just created consists of at least two parts: an inode (a unique identifier) and a file name. When you create a new file ( touch newfile.txt), you are actually creating an inode and a link to that inode. An inode is a file's unique serial number. If you have Googled "hard vs soft link" in the past, you might have seen a reference to an "inode". It is an active act where you, the reader, must also put in the work to get the most out of this article.Īs much as you can, do lots of experiments on your own: try different variations of a command, repeat the command without looking at the article, and repeat it again the next day to fortify your memory (you'll be surprised at how fast you forget things!). To get the most out of this, I strongly encourage you to code along as you read. This article will clarify the differences between ln and ln -s and provide some use cases. You may have some vague idea that these commands have something to do with linking a file to another file. You probably have heard of "hard link" ( ln) and "symbolic link" ( ln -s).
0 Comments
Leave a Reply. |