Hello and welcome to Section one of 4.6. We're going to talk about hard links and soft links or otherwise known as symbolic links.
Also cover the differences between
the the two different methods, and what happens will be copy a file versus Lincoln.
Pretty useful feature. Actually have a lick up its operating system to allow
It's very similar to what Windows does.
If I install software on a window system, usually during the installation procedure, you get a chance to create a
a shortcut on the desktop.
A shortcut is almost the same thing as a symbolic link,
because I can click that icon and open myself where, no matter where it's contained,
could be in a different file system diff different director. He doesn't matter.
The link allows me to reference that, and that's essentially what we use them for in Lenox
So Lynn commands very short just Ln
if we look at our first on our hard links,
the main reason for having hard links as that
there may be a need in a production environment to have a single file that exist in multiple locations
maybe it's a data file. Maybe it's a configuration file. It has something useful
that we want to exist in more than one spot. But what we don't want to have to do is edit that file manually and moving around and copy it ourselves.
That's two too many opportunities to make an error or some sort of a mistake.
So with the hard link Aiken great, the File
As long as I'm within my same file system,
and all I have to do is change the original file and all the links that point to that original file will also be updated.
You're not actually using any additional storage space doing this because
all you're doing is adding an additional I knowed
referenced to the original file, and we'll also look at how we confined
that information once we've created some files of this type.
If I delete the linked files, as it says in my last point here, the original file does not get deleted,
so that's an original. Or that's a big difference between hard links and soft links.
Soft link. If I delete the original file, it will remove the data from me from the linked file
are up. Sorry will rule of the data from all the files that were linked to the original.
But the soft wink or the SIM link, as it's known, lets me create links across file systems, which is pretty handy because often
many file system. Dani, Given Lennox system, we want to be able to have maximum flexibility.
So a few flags here, the normal ones will use today are the dash s for symbolic links,
and we can also use dash beef for verbose information.
Now, once I go through, the examples of creating links will see how they look within the shell itself. The Bash shell will color code
and change the background name of the file,
the background color rather of the file name
to give us a visual indicator as to what actually is represented.
And then we'll see that there are also
references in the long listing of the foul showing us and l
for a hard ling file and asked for a softly file.
Uh, I mentioned a little bit about copying, so we'll go ahead and do a couple of examples here, and we'll see how this works.
All right, let's go ahead and open a show.
I will make myself route.
Apparently I have fat fingers. Today.
and Control Shift Plus will make my found a little larger.
She'll make it one more larger,
and we'll go full screen,
I made a directory called Lynx Underneath My
My Home directory for Root.
This way I can put some files in here and demonstrates all the techniques.
I've already created a file called my file dot text,
and it just has some data that tells me what's in the file, and we'll see why this is important later.
All right, so let's see my file. That text had important data or configuration information.
A lot of applications have a conflict file that sets a bunch of variables, a bunch of different data elements.
So that's a good reason why I might wanna have multiple copies with one master reference.
So what I can do is run my link command.
I'm using tab completion, by the way. I just type and why and hit Tab. And this is the only file that matches. So it'll expand my file. May we covered that a little bit earlier in the course.
All right, now I'm going to link this underneath temp,
and I will call it my file
if I do along listing here. We see now that
I have a blue background that shows me visually that this
file is now hard linked to something else.
If I do a long listing in my temp folder, also using tab completion
it also has that that blue background.
So to demonstrate the fact that that filing temp will get my updates,
create some new data.
Will a pendant to my file dot text.
If I can't, My filed a tax. We see the new data is there
also can can't cat the
And it also contains the new data.
we got a couple actually. Looks like one thing first. I will.
Yeah. The one that I didn't want to show was when I created my father. That text was originally here. It only had one. I knowed
once I linked it, I see that it has to. I notes,
I wanted to point that out a little bit earlier, but it's okay. Well, it's an important thing to remember,
because if I if I run the L s command with the eye option, it shows me that I know numbers.
And now I can see that
the one I know that my file that text originally was
is now linked to two different files. That's what the two represents.
So I can actually run the find command
to show me all files that are linked to this particular I note.
So search from Root and Ron find Dash Einem
stands for I know Number 1637468
and give me a message about one of my temporary follow systems. Don't care about that. These are the two that actually matter.
The original was slash root my links. My fault. That text
and the other followed which references that same file. A different location
is my file hard link dot tax. Underneath the temp folder.
multiple copies in different directories of a single file,
but it does not let me do this
across file systems.
So if I try to run that command again,
my file dot tux, I'm gonna create a new link
And I'll call this one. Also, my file
quote my file, uh, hard link, just like the other
tells me I cannot do this across devices.
I can't do this with symbolic links, but with hard links that has to be within the same file system. Different directories are fine, but same fall system.
Okay, so let's talk about soft links now for a moment.
Let's create a new file
and put some data and it will say this is my file to that text.
Redirect that to my file to text
how I've got something to work with.
I remember soft links or some links
can create links and other file systems.
So I know I've got a file system here. I'm dating too.
So let's create a link.
my phone to dot text.
We'll link that to my data, too,
and we can give it a name there to, um,
So lets me create the link.
But when we look in that folder, we noticed that the link is listed in red
and this tells us that
the link is broken. It's it's not. It doesn't work.
trying Kat, that final
tells me to meet levels of links. There's something it just doesn't work because what I didn't do anyway, what you need to remember is specifying the absolute path when you make links of this type.
That way, there's no there's no confusion. If you look again at what my data to contains,
it just points to a file that appears to be in the same directory, so it doesn't know where my file to dot tax not the original one is.
So I'm gonna go ahead and delete that,
and I will make the link between again. This time
I will specify the absolute path
helps If you spell right,
so slash root slash links my file to doubt text.
We're gonna link this to my data, too,
and we'll call it my too
Now if I look here, my fell to the text doesn't look any different.
It's just a soft link and the other location,
but we can review it there.
Now we see that it's in blue, which is the correct color for a operational link.
And the arrow points us to the actual file.
So if I were to can't
soft link text. I get my original file
and I can prove that this link works correctly.
This is new data will send this
And if I can't that file again
now, the new data is there.
this soft link in a different file system actually contains a link back to the file
that is here underneath slash would stash links.
I can also do this with directories,
So let's create a director here. We'll call it
and I will copy my file to text
and all their fathers. There it is.
the directory to a new directory.
You know, use the full path name again.
files. And I'll link this to my data.
Well, then we'll have a look at that directory,
to show me that it's
But since it's a folder that I'm linking to, the name of the folder turns dark blue. That's a future of shell of the bash. L
because I look here, my my folder name is Dark Blue as well.
And now, if I look in
the target of the link,
look in that directory,
tipping the wrong path there. Sorry.
So if I look in this folder, I should see my file to dot text,
which, of course, is the same as the one nets,
uh, curly and this temp files folder.
So it's very handy to have this flexibility.
So now we can see how I can
created a single file haven't lead to multiple places with a hard link.
Doesn't use any additional storage,
but I can use soft links. Thio replicate more or less that same activity within different directors, also within different file systems.
Now we can see that there are
some file system tasks that I've already discussed a little bit. For instance, finding a file based on its I knowed number.
I can also do something interesting where
as a units administrator, frequently you have situations where you're running out of space.
So what I could do is create a, uh, let's say, I had a partition like root, and there's some logging being done to root who's about to fill up.
If root fills up, there's a good chance your system will freeze up, probably will also crash.
It's just very sensitive, too,
to running out of space because it needs to have the right data as the operating system does its work.
is create a new file system with some space to spare. I'll make a folder there called Logs,
and when I can do is go to my current file system here. I just have a name current file system for reference, but it could be anywhere.
I could move off the current logs to the new location,
plenty of extra space for them to continue to grow.
Then, if I remove the current folder where the Logs
current director of the logs were stored,
all I have to do is create a soft link
from the current folder name to the new fold ring.
So by software that's trying to write to the to the current logs file will now get actually redirected to a new directory and another file system with room to spare.
And this is awaiting to kind of limp along until you can fix the problem properly.
You probably don't want to do a lot of work like this
without cleaning up after yourself, because eventually
things will get complicated and you'll
probably haven't increased chance of deleting the wrong thing or not Remembering something is linked. It can get tricky,
but it's a good way to
get some temporary relief from a situation where you're running out of room.
All right, so we looked at the the Ln command. We also saw how the L s command could be used to view files
in the shell, seeing they're different colors and different features. We know that there's an L in the first position for a soft link,
and we know that the file will be a light blue with link is correct. It'll be read, the link is broken or if there's a bad reference.
And then we also saw with hard links that the background of the file name turns a light blue when those air created.
All right, this is the end of the links section. Next, we're gonna talk about
proper locations for different files in the operating system and some of the utilities you can use to help you deal with that.
All right, See you there. Thank you.