I'm adding this lecture after I recorded the rest of the lectures for this section of the course, just
because it occurred to me that I keep editing files on the remote server using a tool called Vij, some
people call it vem.
I call it Vij.
And you may not be that familiar with it.
And I'm not sure that I gave enough instructions to actually enable you to use it usefully.
So this is just a short lecture that gives you a crash course in VI.
So I'm going to connect to the server.
So I'm connecting.
And I'll clear the screen and I'm in my home directory.
OK?
And I just saw that by typing TWD for print working directory.
And if I want to say go up a level, I can dot dot to go up on level and last list the files and I'll
go back into TC's.
OK, so inside of that I have two files.
I want to create a new file which I'm going to call test.
I'll create that by typing the command VI and then test text because it's a text file and that opens
the VI editor and the VI editor is incredibly powerful and I'm not going to go anywhere near through
all of the commands that are available to you, but I'll give you enough that you'll be able to do things.
So when this is first opened, if I want to be able to insert some text, I'll type the letter.
I actually I think I hit to know there.
But anyway, I and that you notice in the bottom right and the left hand corner, it now says you're
an insert mode and I can, I can type things now I have a typo there.
If I want to get rid of that and change that wi to an H like it should be, I have to hit escape.
That gets me out of edit or the insert mode and then I'll use the arrow keys to get over top of that.
I'll type the letter X to delete that X I to reinsert and I will change it to an H and now I can go
back to the end of this.
I can type things and now I can type more and again I'll get out of in certain mode by hitting the escape
key.
Now that I've done this, I want to save it.
So I'm going to type a colon shift and then the shift semicolon, which is the colon key that brings
up the command.
And in the bottom left hand corner, you'll see it's now a colon and I'll type W four.
Right.
And that writes the file.
And if I want to get out of here again, I'm not in insert mode.
And if I am, I would hit escape.
I'll hit the colon again to bring up the command and I'll take a cue.
And now I'm quite out of it.
And if I clear the screen and type ls to list the contents of this directory, there is my test text
file and if I type cat to actually print this out, the contents of it.
Test, test, text.
There's the file that I typed.
If I want to edit that file down Vij test text and it brings it back up.
Now let's say I want to have a new line here.
I could hit I and then press return or I can just type O which will insert a new line and put me in
a certain mode and now I am in insert mode period hit escape to get out of it.
Colden to bring up the command a bit wq I can do the right and quit as one command and we're good.
Let's do it again.
Let's say I want to get rid of this entire line.
I can type D and that will delete the entire line.
I can delete this line to D and get back and insert mode and type some new text.
Now I'm going to get out of insert mode and I'm going to go y y to copy y y copies the current line
and then P to paste and Peter paste and Peter paste and Peter paste.
And I'm going to go up to this middle line and I'm going to delete the words sum by hitting X four times
X X, X, X I again.
And now I'm going to type a word that is unique.
It exists nowhere else in this file and I will call this Treva.
OK, I'll get out of insert mode, bring up my command by typing the colon and now I want to look for
the word Treva.
So I put a slash and Treva and it's case sensitive.
So I had to use the capital T and it will say, hey, there's the line.
It takes me right to the line that has that word.
And if I hit N for next, it jumps right to the word Trevor and I could delete that and put in OK,
I've got the wrong spot.
Mary escape colon WQ to save and quit and we're done.
And that is our crash course in VI.
Now I've added to the resources for this page a cheat sheet for VI.
And if you don't like VI, there are other editors.
I think there's one called Pekoe, which I never used peacoat test text and that brings up something
that actually might be more useful for you.
So this might be a little friendlier for you.
I don't like it.
I find VI extremely easy to use.
You have to learn basically three or four basic commands how to get into the insert mode with an eye.
The escape gets you to your command of the insert mode and typing a colon brings you into the command
bit where you can save and quit.
And that's sufficient for our purposes, for this course.
But if you want to learn how to use Nano, just Google it and all the instructions will be there.
I want to exit right now and it looks like Control X gets me out control X and we're OK.
So that does it.
But it's is really easy to use in.
I strongly encourage you to learn it.
It will make your life much easier when you're managing configuration files on a server.