What is the difference between a physical link and a symbolic link?

Julioarenas
6 min readSep 22, 2020

--

If you’re here is because you want to understand how links work, but before we understand it we must know how certain things work because it is an environment variable and how it differs from the other type of variables, also how the PAHT variable works, which has to do with the links in a script and that means the ASCII text within the text and how we make bash read it, well, actually there are many things.

ENVIRONMENT VARIABLE:
The environment variable is the one that comes by default and predefined internally in the operating system or language, if we modify them we can change different aspects of the operating system that we have or environment that we are.

LOCAL VARIABLE:
The local variable is one that is created by the programmer, using a programming language or operating system.

PAHT:
It is an environment variable that saves the command paths, which are also environment variables, and because of this PAHT is the most important environment variable, if we change a small portion of the command path it stops working, PAHT saves the paths of “pwd , ls, mkdir “and many more, in other words, PHAT saves the LINKS of these commands inside an executable file.

RELATIVE ROUTE:
A relative path refers to a location that is relative to a current directory. In other words, its relationship to a file or directory depends on where the user is located. The closer the user is to the file and directory, the more relative it is. Relative paths use two special symbols, a dot (.) and a colon (..), which means the current directory and the parent directory. A colon in a row is used to move up in the hierarchy. A single point represents the current directory.

ABSOLUTE PATH :
Absolute paths indicate the location of a file or directory from the root directory of the file system. That is, to move from the source, that is, the root directory, to where we want to go.

SCRIPT:
A script in LINUX is a file that contains different commands that are interpreted by the shell to execute them by means of its path or rather its LINK. The shell executes them as if it had written them in PROMPT. When we write a SCRIPT in a file we do it through a LINK called SHEBANG which gives the BASH path to read the script.

ASCII:
ASCII code is a digitalization of human language to computer language, that is, it replaces letters with numbers which are interpreted by machines in a bit manner.

I mention all this as a basis for understanding the links and their logical relationship of its operation, so let’s talk about links.

TO WHAT YOU HAVE COME TO!

LINKS:
The serves us to access the folders or files in a much simpler way, without the need to move through the entire HIERARCHY of the directory, through the RELATIVE ROUTE and the command cd we go from directory to directory until we stop where you want, but if instead we create a link to go directly where we want, it would be less time and much easier those are the links, it makes our life easier and they are everywhere, there are some that come predefined and are in the environment variable PAHT others to communicate or read directly as SHEBANG that places BASH to read the file.

In Linux a link can be physical or symbolic:

PHYSICAL LINK
Physical links can only be created for files and not for directories, the PHYSICAL LINK is the name given to a file in another location which contains the path or information that is put to it.
example:

create a link from the current location;

PROMPT ~$: home/ holbertonschool-low_level_programming

WE CREATE A FILE ~$: emacs bettyCool

WE CREATE THE LINK ~$: ln bettyCool holberton

We put “ls” to see the content~$: ls; holberton

There are two files, this means that if I enter holberton it will show me what has bettyCool, since both have the same content. And a characteristic of the PHYSICAL LINKS is that if you delete one of the two the other still exists without any problem.

SYMBOLIC LINKS

The symbolic links have the same function as a physical but the difference is that it does not contain the data of the file, instead it points to that folder or to the registry where the data is located. In other words it is like a shortcut in Windows that when I click it takes me to where the content I need, it would be like a kind of hyperlink of a web page. If the destination file is deleted the symbolic link will be unusable, because it will not be able to refer to the file it was pointing to, since it is not there.

Symbolic links have the same syntax as the physical one but with a small only that we add the option -s to indicate that we want to make a symbolic link.
Example:

In the download folder you have an absolute path from where the file was downloaded;

PROMPT ~$ : cd/home/holbertonschool-low_level_programming/

PROMPT ~$ : ls/home/holbertonschool-low_level_programming/

we have files ~$: bettyCool
We create the symbolic link from the current path and we create a new home file called ENIAC that points to the bettyCool path.

Now we see that after creating the symbolic link we go to the home folder and with “ls -l” we will see that ENIAC points to the ROUTE of bettyCool, and if we enter ENIAC it shows me the content of bettyCool, this would be the same and practically a C pointer.

When you open files or directories very repeatedly, links are your best tool to shorten time and eliminate headaches,
use them as you will look very professional in doing so.
Thank you and I hope this information helps you with Linux.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response