1
00:00:06,639 --> 00:00:08,220
Okay, let's check
out some links.

2
00:00:08,800 --> 00:00:15,250
To start with, I want to show you
LS L in the root of the file system.

3
00:00:16,530 --> 00:00:23,329
So LS L is showing the long listing
and there we can see some symbolic links.

4
00:00:23,910 --> 00:00:29,932
So bin is pointing to user bin and
lib is pointing to user lib and sbin

5
00:00:29,932 --> 00:00:35,954
is pointing to user sbin. Now, why is
that now? A long time ago, the file

6
00:00:35,954 --> 00:00:41,977
system hierarchy standard was dictating that files that
are required for booting your system are in

7
00:00:41,977 --> 00:00:48,000
bin, and administrator files that are required
for booting your system properly are in sbin.

8
00:00:49,700 --> 00:00:54,659
And then we had user bin
and usersbin with us for binaries

9
00:00:54,659 --> 00:00:59,619
and super user binaries to be
available once your system was booted.

10
00:01:00,250 --> 00:01:05,319
That made Sense in the 1990s, but
later it did not make sense anymore.

11
00:01:05,319 --> 00:01:10,389
So the FHS changed and they
removed the requirement for the bin directory.

12
00:01:11,469 --> 00:01:18,187
But you can't just remove a directory because many
organizations are creating scripts and other components or applications that

13
00:01:18,187 --> 00:01:24,905
refer to the location of the file in a
hard way. So if you will be referring to BinPassWD,

14
00:01:24,905 --> 00:01:31,622
for instance, your script would fail to. And that
is easily fixed by creating a symbolic link, which means

15
00:01:31,622 --> 00:01:38,340
that bin is pointing to user bin and
the result is that they show the same content.

16
00:01:39,599 --> 00:01:44,280
Then, about a hard link, let me work
out an example where you can see hard links.

17
00:01:44,969 --> 00:01:51,224
I'm creating a directory and let's create
a directory course one and let's create

18
00:01:51,224 --> 00:01:57,479
a directory course two and then
I'm going to create a configuration file.

19
00:01:58,310 --> 00:01:59,000
Now
a script.

20
00:02:00,129 --> 00:02:04,500
Let's use a simple editor, nano.
I'll talk about editors later. So for

21
00:02:04,500 --> 00:02:08,870
now I want to keep it
simple and let's call it Setup sh.

22
00:02:10,250 --> 00:02:15,689
And in that script I'm
going to use Echo hello world.

23
00:02:17,030 --> 00:02:22,599
Of course this is oversimplified, but you don't need
to make it more complex to make a point.

24
00:02:23,099 --> 00:02:28,009
Let's say that for course one we need the
Setup sh. We also need it for course two.

25
00:02:29,229 --> 00:02:34,689
Now what is the
problem? Well, I can of

26
00:02:34,689 --> 00:02:40,150
course copy Setup sh
into the Course 2 directory,

27
00:02:40,149 --> 00:02:45,609
but if then my
script has changed Echo hello

28
00:02:45,609 --> 00:02:51,069
world, as well
as oceans, whatever.

29
00:02:51,770 --> 00:02:55,275
So now my script
has changed and then the

30
00:02:55,275 --> 00:02:58,780
problem is that we
have two independent scripts.

31
00:02:59,360 --> 00:03:03,290
If I would use LS
set and make that a

32
00:03:03,290 --> 00:03:07,220
long listing so that
we can see the properties.

33
00:03:07,719 --> 00:03:12,810
You can see that the Course 1 setup
sh is bigger than the Course 2 setup sh.

34
00:03:14,909 --> 00:03:20,969
Now, can you imagine that you have
several directories that all need the same script,

35
00:03:20,969 --> 00:03:27,030
and once you update the script, you
want to update all of them. That's where

36
00:03:27,030 --> 00:03:33,090
a hard link comes in handy. So
I'm removing Course 2 setup sh, and I'm

37
00:03:33,090 --> 00:03:39,150
going to link LN for link Course
1 setup sh to Course 2 setup sh.

38
00:03:40,689 --> 00:03:47,669
So now that I've created my links, let
me do an LS IL on start setup.

39
00:03:50,449 --> 00:03:52,770
And what do we see?
We see the hard link.

40
00:03:53,669 --> 00:04:00,400
Now, how do we see a hard link? Well, that's
why I included the I. I is for the inode number.

41
00:04:00,919 --> 00:04:04,569
This is the inode number.
Every file has a unique inode,

42
00:04:04,569 --> 00:04:08,219
and this unique inode contains
a complete administration of the fal.

43
00:04:08,979 --> 00:04:12,495
And you can see the inode numbers
are the same, the size of the FAL

44
00:04:12,495 --> 00:04:16,009
is the same, and all the other
properties of the file are the same.

45
00:04:16,519 --> 00:04:22,914
So if I change, no matter
which one, like course two setup sh

46
00:04:22,914 --> 00:04:29,309
and I'm adding endmoon and I'm
saving my file. Yes, and I'm using

47
00:04:29,310 --> 00:04:35,705
my LS il, what do we
see? I changed the one in course

48
00:04:35,705 --> 00:04:42,100
two, and the one in
course one has also changed.

49
00:04:42,629 --> 00:04:48,164
So hard links are really pointers to the
same inode. And the nice benefit of using these

50
00:04:48,164 --> 00:04:53,699
hard links is that you can change whichever
one and that will change all of them.

51
00:04:54,300 --> 00:04:59,410
In a heart link, there is
no relation anymore between the original and

52
00:04:59,410 --> 00:05:04,520
the linked val that's different. For
symbolic links, let's get into the Course1

53
00:05:04,519 --> 00:05:09,629
directory and let me use ln
s to create a symbolic link.

54
00:05:10,790 --> 00:05:14,865
And I want setup
sh to link to

55
00:05:14,865 --> 00:05:18,939
install sh again
ls il on star.

56
00:05:19,620 --> 00:05:23,930
And there we can see that install
sh is clearly appointed to setup sh.

57
00:05:24,509 --> 00:05:27,970
It also has a different inode
number, as you can see right here.

58
00:05:28,949 --> 00:05:30,990
But what would happen
if I remove setup sh?

59
00:05:32,189 --> 00:05:36,789
Well, then LS IL on
install sh is is marking

60
00:05:36,789 --> 00:05:41,389
by color coding that
something is going not well.

61
00:05:42,329 --> 00:05:46,240
And that is because the link
has become invalid, as we call it.

62
00:05:46,959 --> 00:05:50,814
So I can look cat oninstall
sh and there we can see

63
00:05:50,814 --> 00:05:54,670
no search file or directory. That's
because the link has become invalid.

64
00:05:55,709 --> 00:05:58,290
But hey, can
we easily fix this?

65
00:05:59,750 --> 00:06:04,543
There we have the current setup,
and yeah, we should be able to

66
00:06:04,543 --> 00:06:09,336
fix that by just creating the
hard link again. So ln for course

67
00:06:09,336 --> 00:06:14,129
two setup sh and we link
it to course one setup sh.

68
00:06:15,209 --> 00:06:19,394
And now I'm using my tree
command again, and there we can see

69
00:06:19,394 --> 00:06:23,579
that everything is back to the
original situation. So it's all fixed now.
