In Unix-like operating systems such as Linux, “everything is a file” and a file
- is fundamentally a link to an inode (a data structure that stores everything about a
- file apart from its name and actual content).
- A hard link is a file that points to the same underlying inode, as another file.
- In case you delete one file, it removes one link to the underlying inode. Whereas a
- symbolic link (also known as soft link) is a link to another filename in the filesystem.
- Another important difference between the two types of links is that hard links can only
- work within the same filesystem while symbolic links can go across different filesystems.
-
-
-
To create a hard links in Linux, we will use ln utility. For example, if you want
-to create a hard link named "hard_link1" to the file "file1" you can use first
-the ls -l command in order to see all files. Then you
-write ln "file1" "hard_link1" and after that if you write down again
- ls -l you can finally see the hard link named "hard_link1"
-created. Looking at that output, using ls command, the new file is not indicated
-as a link, it is shown as a regular file. This implies that "hard_link1" is just another
-regular executable file that points to the same underlying inode as "file1".
-If you desire to make a hard link directly into a soft link, use the -P flag
-like this: ln -P "file1" "hard_link1"
-
-
- Now, you can ask, why I have to use one or another?
- What is the difference? and questions like this.
-
Don't worry, the answer it's easy.., we can use an absolute path from any location
- whereas you want to use relative path we should be present that you have to be in the working directory.
-
-
-
-
We suppose that now you know the differences between both, but, what is the vantages and disadvantages?
-
-
-
-
Pro and Cons of using Absolute and Relative
-
-
- 1)Absolute paths are clearer: who will have to maintain/modify your script (you or others) will be able to know
- every time what directories are involved;
-
2)With absolute paths you are sure the involved directories are the one with the exact path you are writing
- in the script;
-
3)Relative paths are shorter, but you need to be sure of the subtree you're working into;
-
4)You can achieve shortness replacing recurring paths with a variable at the beginning of the script
-
I'm sure that if you read this for two or more times you will be able to pass the quiz
-
-Yeah, right, there is a quiz.
- The best way to learn something it's not the theory, in fact you have to do some practice, if you click
- the button "QUIZ", you can try to do a quiz in order to check what you've just read.
-
-