Problem 2.49

the energy of the charged sphere can also be calculated using Gauss’s law, which states that the flux of the electric field through a closed surface is proportional to the charge enclosed within the…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Discerning Between Symbolic Links and Hard Links

Symbolic and hard links are one of those topics that can get people starting out in Bash a bit confused and mired in the annoying process of distinguishing the two. I remember starting out myself and being skeptical of their usefulness to me. I had been scripting in Bash for about a month and hardly found myself ever using them. While it’s tempting to justify not learning them because most of the time you’re navigating directories, listing contents, and modifying how content is presented through creative use of piping, having a careful understanding of this topic can separate the novice from a serious practitioner. We shouldn’t be content with just knowing a few things, but rather most things about Bash. That way, we don’t get stumped when encountering certain obstacles that do, eventually, require these two links.

It may be instructive to start with an allegory for how a hard link works. A nefarious wizard decides to create a spell that binds two targets together. Imagine two chests. The wizard decides to practice by placing the spell on them, so that anything that happens to one of them, directly affects the other. Their fates are intertwined, so to speak. They’re bound by this invisible, ethereal link that ensures this. If one gets destroyed, so does the other. If one gets defaced, so does the other. The point is that one cannot do anything without the action directly affecting the other. Unless, the wizard decides to lift the spell. In this case, he does and the treasure chests maintain a state independent of one another. Whatever happens to one chest is not the problem of the other because they’ve been freed of the spell. Although, one important caveat of the spell is that a mirror copy is made of the template chest to the target chest. Though they are no longer bound to each other, the effects of the spell are such that the target box is identical to the template box. So if the template were to be destroyed, there would be no cause for concern since the target is a clone. That is what is often referred to as a making a mirror copy of the chest.

Think of hard links as an ethereal thread tying the chests’ existences together.

Now that we have a thorough understanding of hard links, the transition into learning symbolic links, on the other hand, will be much simpler. Think of an exchange between a human and a robot. The human wants to know the robot’s name, and the robot gives a complicated serial ID. The human, naturally, wants something more memorable, like “Clank.” He walks over to the robot and places a name tag stick on it. That, in a nutshell, is what symbolic links do. They give nicknames or aliases to files and directories. A coding example will help cement this practice:

Here, we create a symbolic link to the robot’s name using the moniker “Clank.” As shown in the output listed in bold, we now have a new way of referring to the robot! Do keep in mind, however, that unlike hard links, soft links cannot directly modify the files they point (hence the term symbolic).

Add a comment

Related posts:

Centaur Weekly Update

We would like to share our weekly updates with you on what has been happening in the past week and what are we currently working on. By combining the best elements of decentralised finance with…

Crisis? What crisis?

A friend has pointed me to an article in the Lancet which sums up some thoughts I’ve been formulating about our reaction to Covid-19. Whilst the validation of such a respected medical journal is…

Evasive Driving

Evasive or Defensive driving is a method of tactical procedures adopted while driving through hostile conditions. Generally the objective would be to get away from pursuers or to safely extract an…