Welcome to Cyberia. I t I'm Greg Stewart on your subject matter expert for Lennox Plus,
in part for module three, the systems administration module. We're gonna be covering file editing. So we learned in the past part in part three, we learned a little bit about
I actually learned a lot about how to create files, make directories
learned about the permission set of the file. And now we're gonna learn how to edit any of the files that we have. So file editing comes into play a lot as a systems administrator, and you're going to have to edit file such a cz, the etc result dot com,
etc. Network system, fig or assist config network,
etc. Host files commonly gets edited adding host names to act as your D. N s. And there's a lot of other files that you can edit. There's many files. If you need to edit a script that's actually in a text file, you can do that before launching it.
So understanding the file editor is a very, very good skill to have.
And it's one of the skills that, to be honest, has a very steep learning her.
This is not like your standard editing that you do in a note pad document or a word document.
You're doing this. You have to remember that you're doing this all from the command line. So it's a little late, like, slightly more difficult than you,
then you how you ended things and windows.
But if you're here in your systems administrator than you, you surely want to learn about how to do this. Become good s. So I'm gonna give you the basics and help you to understand how to become
good. It's a good file editor inside of Lennox Window.
So we're back at the L A X box, and I'm gonna blow it up again.
Okay, I want I'm looking at here is my, um
is my terminal window
back of my Lennox test top.
And what I've done is I've actually created a file for us to look at that. We can play around with it,
Otherwise, we're gonna create some other files as well. So let's jump into it. Let's jump into it from me. Ah, simple point of view first and just create a simple text file and again for this one. I'm just gonna do the cat command
with the greater than signed.
I'm actually gonna drop this. Let's let's leave it here in this director's cat
and I'm a name. This
now. It's dropped me into editing mo here. I'm gonna start creativity. So I'm just gonna take this as this is a test file.
You're learning about
violating Alexis put there,
and I'm a hit interests a couple times in the control d to get out of that mood and to say into right way
So let's check our permissions on that.
It's doing L s Dash fell
and the file name, which is test file.
And it looks like I've got Reed right
as the owner of it. And everybody else just has to read. I'm fine with that. For now. You could change if you want to have rewriting, execute, but we could do everything we need to do. Just rewrite permission through this file.
So I'm gonna lead the file commissions alone and really just jump right into editing this file.
So there's several. There's a lot of different file editors out there for Lennix and you can download several when you feel comfortable with what I originally used when I was learning, Lennox was following her to call them be. I am.
And that is just a different version of the V I editor v. I stand in Lenox V. I stands for It's the editor actually stands for visuals. Just takes the first to be in the eye from the work visual.
It's a visual editor allows you to go in and edit thought of files at things, change things to lead things and then save it and right back to the desk, all within the command line
without having to go through the hassle of opening the file on the goofy
typing it, saving and closing et cetera. Just doing save as you could just do it all from the command lasting or have to jump back out.
And then again as a reminder if you're you know, if you're in a situation where you need to remote into somebody's machine and you're using sssh client
terminal client, something like putty and you're gonna need to know how to do file anything from remote workstation.
So V I stands for visual so if them or B I am is very much improved in the eye. Improved
man. Just take some of the characters strings together
Them is a little bit different. Started off using them, loved it. And then I got to using B I and I've become proficient with B. I was also Nano and a couple others that you can download out there and I'm gonna let you google around, find which file it. Or do you think you
you feel most comfortable with Google? Find some of the websites with the file editors on it. You can see what the differences are again. Lennox is a community of users that, you know, improve the system on a daily basis
so they may come out with a new final editor on a daily basis. You never know. So they just made up improve and upgrade the current by letter that using
the purpose of this course, I'm going to be focusing on using the V I editor and I'm gonna show you how to use that.
So to get into V, I you have to simply use type V I
that doesn't actually take you anywhere you need to file May
someone to be I test file
and dropped me into my file editor
and you could see the very top shows. My first line of text. This is a file we're learning about violating in Lenox.
So what can I do from here? If I start just typing things, it's not going to really do much for me, cause right off the bat when I open a file and v i n the editor, it's open and was called command mode, and this moment is just strictly command mode. I can use some of the keys on my keyboard, too.
Jump around in different positions in the file. If it's a super long file, it's helpful
to be able to do that.
If I type a just, ah, lower case K, it takes me to the next character,
and then I can start typing immediately. Okay, But I want to do that.
So I'm gonna back spaces. I'm actually gonna hold on to escape this
I'm going to accept this mode.
about saving anything.
and I'm going to clear and I'm gonna open that back up Since I messed it up.
I want to make sure we do this the right way. So the eye test file
case, We're back. So thio the commands that we can use
in command mode? Very. And what I've done here is I've written up a
instead of using a slide, I've written up
a file here to show you some of the different components. So I'm gonna put these side by side
this just slightly, a little bit smaller.
while in command move.
I could move around so I could go if I had a choice to move one character to the left
on the current line that I'm on, However, I'm in the furthest left. Most character. At this point in time,
Jay moved down to the next, moves down to the next line
and you can see that I can't go any further. Those little teal days was little symbols there.
That is the end of the documents. Just two lines at this point time. Because remember, I hit enter after I did the line cup to interest to get four to control D.
So I can't go any further. Okay, so but if I go back up
I want to move up to the previous line. A hit kay that takes me back up to the previous line again. J goes down warm, Okay, Goes up one.
I'm not sure the logic or reason behind what these keys hot keys are, why they're named what they do.
Not really concerned about it as long as you know what they are and what they do. Which is why there's a pretty steep learning curve when it comes to filing. And Lennox,
there's a lot you have to memorize and understand ableto navigate the file and we're starting out with super simple file here. This is two lines. He imagine having a file or ah, script with, like, 3000 lines of code. I mean, it would be it would be really difficult to get Get around the file. So you have to understand
different honkies. J and K take you up down one file line.
move right. L moves me right. One character. I could go. One character timeto right. H goes back to the left.
I'm not sure why l wouldn't be left, but it's actually right. So there's some things for slightly confusing. And if I just want to go to the next word I hit. W takes me to the next word on the current line. Tell me you got to come to you
and why we're doing this. Why? There's even a command mode, because instead of story having to start the very beginning Once you go into editing mode, which we're gonna get to next,
you can go and put the cursor wherever it is that you want to start. Because you remember. You have to know that
you can't use your mouse in the command line to drop the
cursor wherever you want it to start. So you gotta use the keys to go around.
So I'm gonna go back.
Yeah, to the very beginning.
Okay, Um, and then moved to the previous move be would be moved to the previous beginning of the word on the current lines. Let's go. Word, word, word, word, word. And I'm gonna go be takes me back.
Takes me back to the first word of the previous first layer of the previous word.
Um e moves to the end next end of the current line. Next. The end of the word on the current line. Okay,
so I printed this document up. Firing drew up this document so you could see visually see some of the things on there that will help you to get around the file. The V I file editor.
Well, let's look at a couple more
control F control dash lower case f You could scroll forward one patient again, right? I don't have a long enough. I'll thio be demonstrating this, but we're talking like code files with 3000 lines. You could go off a page at a time instead, instead of line by line
G moves to a specific line on your file. So if I type and let's go back over here,
go back to the very beginning
and I'm gonna take in
three. H would move Meteo. No, I'm sorry. Three of three g or four Jeanne moos me to the fourth line, but I have four lines, so I'm gonna do to g
uppercase. And that took me right down to the next line again. Not a great example of this file. And just try and get you some of the different items that we get to a longer father created specifically for this task.
Okay. And there's some other ones. H moves relative to the top of the screen. Three actual movie to the third line from the top. L will move you to relative to the bottom of the lot of the screen.
So three l a movie to the second last line, three hour movie to sector last line. Extreme
too. Well, actually, as a typo.
um, and getting out of the ice. So once you're done, you're edited and all, You've got to be able to get out of it like a shows. Earlier when I made a mistake, I was trying to get out. Well, it's making it saves.
I'm basically gonna hit my escape key. That puts me in an escape. Keep with you in the command mode
and I'm going to do a colon and you could see my cursor dropped to the bottom of the screen. It's flashing their I didn't call him.
Now it's gonna be asking me to call for a command to accident. Knows that I'm in a move or I'm gonna start. You're gonna win it to get out of the editor.
exclamation bang! And Lennox
that's going to quit the editing and is going to do without
committing any of us say of any It's not committing any save to the file, and he changes I made is not going to commit. So what I want to do is I'm gonna do use that one if I've made a mistake and I just want to get out and then get back into it. The file. How original Iwas We don't mess up anything.
Okay, so I'm not gonna do it so we can show you all w
with a bang hit. Enter on that one.
You can see here at the bottom Mrs Text filed testified about tax. There's two lines and 67 characters written
okay, and I and I've made ah, that's basically my safe. But so if I'm in in the middle of editing a really large file, you want to make sure to do that, you know, escape and then colon,
right? With bang as you're safe, it's gonna save everything that you've made so far without closing the file. Okay, this is also I apologize. Bonuses. This type of as well just commits the changes that you've made
Z Z writes the file Asbestos currently edited and then exits. So it's just basically making a save and then getting out. Capital G Capital Z
e Bang actually reloads the file, killing any of the changes that you made and then the colon with a bang just by itself. You can actually run Shell Command than the Ender, and it will do that and I'll show you the output up as well. So there's lots of different ways that you can get out that it's safe.
Well, I generated when I used most of the time which was listed in this document. Hit the escape key
going rate. Quit with a bang
that's going too right what I've done and it's gonna quit.
Let's go back into it.
No, it's not another command. So it's not an editor. Commanded a bun, too.
But you may be using little red hat or Fedor sent Toss, and that would be economic use there
in the bun to is gonna be right quit just as I suspected. So you right quick
and, um, out You could do right. Quitter. Right. Quick bang. Depending may throw an area that says, uh, this file. You know, I'm a ***. Weird air. If you do a bang him just right, quit and avoid the air and get out.
what a large file would actually look at what actually looked like and how we can use to jump around and how those
items that we have in this little text file here would actually help us navigate a larger file.
what I did is I created a document that is, I didn't actually created myself a copy from a Lennox page that
I've talked about. It was a basically a short bio on Linus Torvalds and what he's done having group excited us. Let's take a look at that. It's the Linus t dot t. Eckstine.
So again, I'm gonna do V I to get into my editor. Remember? I could do cat just if I'm gonna look at it
but not edit it. Right?
So it was just I did a couple paragraphs, but I want to read it, so I'm gonna do clear first.
I'm gonna do V I minus two text has dropped me in. And as you can see, the very first line of the very top player
you can read through it. Last Tour holds is the world's most famous computer programmer and also its most famous fan. This is obviously biased. This comes from a Lennox website called Lin Foe.
You can see here on the very last line I put taken from www dot info dot org's
four slash Linus dot html. This is not my own work. Just wanted to get something that was a little bit lengthier than the light created.
They won't have to come up with a bunch from off top my head to fill an editor. So here we are in the 1st 1st line limit and never if you do in L. A. You're moving to the right one character of time doing h
I'm moving to the left if I do a J and could move down the line
down to the next next line.
Now, once on about this is what you've seen here, right? Remember how I created this file?
A trade of this file, using the cat
command with the greater than sign and giving a name? What does this Trust me into that cat Editor what that's doing is that unless I am type What I did here was, I just kind of apparently typed
as I went. It just went to the end of the line onto the next one. You can see we're operating here. This shouldn't. This is not proper oration have looked like this or that. You see, that just goes to a T. That's because the editing that I did there was not
basically, you know, didn't have word rap on it. It just kind of went around, Went around, didn't actually split like it should.
So when you're in that cat emoji to actually hit, enter in the end of everyone, you're typing to get to the next line. Otherwise it'll look like this. Remember that J and K
bring you up and down one line so it sees this whole first paragraph. It's one line. That's why I'm skipping ahead
entire paragraph here
so things to think about,
if I want a stiff, I'm here on this beginning. L and I want to get all the way to the right as far as I can if I want to get to work. Programmer.
All right, No, we fix this here. Hold on. One second. One fixed. This
only gets the word programmer, but I don't want to do it.
One character at a time. Okay?
I can go to just W which will take him to the end of each word.
Move to the next word on the current line.
And that programmer.
Now, if I want to start editing, I have to get into edit Moto have to type I or in for input.
Now, I could start typing and actually wanna delete this on to make it a p
if I want to go back,
okay. And so it's a shift here.
Student escaped its command mode
Yeah, right. So must do a quick bang.
I want to go back in,
get funky at times. So I'm gonna go
w get to the first letter of wars programmer,
go and actually, and I'm gonna I get into input mode
and I can start editing.
I don't want to add more.
Okay, that's obviously by doing that investable paragraph and everything, but I'm just giving you an idea of how you get in at a file.
I want to go back to command mode. I have to hit escape. So I just try to hit Q to quit or w two right. Quick acquitted. She's gonna actually type out front right quick.
Don't do that. So I'm gonna go out and get out of that.
So now that you've seen what file editing can do, I'm going to make your right. Actually, I don't want to do right quick, so I want to mess up the file. They're just gonna do a quick bang to get out without saving anything.
So that's file editing with V I. It's fairly. It's a It's a good tool to learn to use you as a system administrator again. Like I said, you'll have Thio edit too many files at sea host files one of the major ones like we talked about.
And there's lots of filing that you can do and learn. And again, this would be, uh,
um, I'll put this up here for a minute. You can look at it, but this is basically what you want to do. He composite at this point, and Scrabble have scribbled down all the commands that I put out here so you can understand better how to use them, memorize and get into where they're just second. A tree. You can get zip around a file that's super long, and so it doesn't take much time.
So that's file editing in a nutshell. With using B. I Like I said, there are many other command. Our file editors out there
choose one is your preference.
Do you like them? Ben was a little bit easier to navigate around. I've become for showing the eye. So I stick with the I
I would caution you to just stick with what you're good with. If you get to a system that doesn't have the eye, you can always reach out. Downloaded If the firewall ports on block, man. So that is file editing, and that is part end of part three.
I'm sorry, Part four of Module three,
and we will kick off the next part here shortly. Thanks for watching