Hey everybody and welcome to the next video on the Linux operating system module.
Now in this video we're gonna be going over something called symbolic links symbolic links also known
as SEM links are a special type of file that can reference another.
Now this can be referencing a directory a file folder etc. So an example of this is that we have slash
temp and we have a file called text that text.
Now we can create a link on my desktop at home Brandon slash linked text that points directly to Text
text.
So when we modify like that text it updates text that its and there are two types of links are soft
links and then hard links.
Now soft links can be used between two different file systems.
They targeted references so in this case it was temp slashed text that t x t if that file ever gets
removed.
The hard link does not get removed it stays it stays in place and it doesn't have the software it doesn't
have to move.
It stays in place.
It won't go anywhere but it won't reference a file any longer.
Now this also links directly to the I know table and removing it only removes the reference but not
the file.
Now it's important to note that in a soft link it gets a new I note no for that particular link but
it will still reference the file location for the other so we also have hard links so this cannot be
used between two file systems and the the the target itself must exist when creating the link.
Now dead links.
So when we talked about soft links and when the target does not have to exist.
This is what's called a dead link is when the target does not exist.
These are good to remove.
There is a perfect escalation techniques that you can use around dead links I'll leave that to you guys
for some homework to read up on but there are a few different ways.
Under certain circumstances that you could escalate as root without or we're just using dead links in
some fashion.
Now let's take a quick look at the symbolic links right.
So what we've got here we have file called test that t t cat.
Now go.
Right.
Awesome.
Now to create a link it's Ellen.
Now that's the core command.
Now if you want to create a hard link you would do a test at t 60 and then the name of the linked would
you want hard link.
Right.
And we do a quick here.
We can see we have a hard link here.
Right.
So if we want to create a soft link it's Ellen dash s same parameters soft link.
Now I want you to notice the difference here.
You can see a soft link actually shows the reference to where it was located and if this was in a different
directory you would see the full path to text at the extreme.
Now if we cut out a hard link we get the same answer cut out soft link get the same answer and we cut
out test.
Steve we get the same answer.
If we modify the file it will again show the same thing.
Now let's take a quick look at something.
So we're going to show the I know numbers.
So I would want I want you to notice something here.
You can see the hard link has the same exact I note.
No this is important because it shares the same.
I know no just with a different file name.
So these two technically point to the same block where the physical data is on the disk is actually
sitting.
Now a soft link points to the I know table as a reference.
So if we go ahead and delete.
If we delete texts that t 16th and then we rerun that unless command we can see two things.
Hard link it looks perfectly fine.
There's nothing there.
It still points the same I note however soft link went red which means that it's considered a dead link.
So if we try to cap soft link it's going to say no such file or directory because text that text does
not exist on the I nodes table now hard link if we can hard link we see the exact data.
The reason this is happening is because it shared the same copy of the I note that the actual file did.
So it has an exact location of where on the disk that data actually sits and what block it's in.
So because of that it's able to still view the data as well and it can be essentially a replacement
for that text file.
So if we want to rename it hard link to the texting.
Now our back to exactly where we left off.
Again there's no indication here that it's a link.
However with the soft link we can see this L which labels the link.
And now our soft link works.
So if we can soft link we get a file.
So understanding behind the scenes of how this works is important.
Go out.
Go ahead and play around with it a little bit.
There's actually one more thing I want to show you.
If you want to search for a link again you can use the find command.
Right.
Fine and then we'll look in the current directory and we'll say the type now the type we want to look
for is link.
So we're looking for soft link.
The reason this won't work for hard link is because it is considered a physical file.
It is considered no different than the original test that takes a while a link is still considered something
different it's a different type of file.