OPS145 Lab 5 Newversion

From Littlesvr Wiki
Jump to navigation Jump to search


!!! THIS PAGE IS NOT READY YET !!!

One of the most common tasks a system administrator will do is to modify some configuration. Almost all services on Linux servers are configured using plain text configuration files.

So far in the course you've been using a graphical text editor. But since Linux servers don't have graphical user interfaces (GUIs): you have to learn to edit text files on the command line.

There are several common applications for command line text file editing. We're going to learn vi. Even though vi is a frustratingly annoying application to use: it's the one available on any Linux system.

vi

As you go through your Linux courses: try to think of vi as a necessary evil. We're going to learn the absolute basics necessary for you to be able to accomplish any task a systems administrator would need it for.

Modes

One of the confusing things about vi is that it can be in one of two modes at any time: command mode, and insert mode.

In insert mode it functions more or less the way you'd expect a text editor to function, except depending on your setup: the arrow keys, delete key, and backspace key might do weird things. Otherwise: when you press a letter key: that gets inserted into the text.

In command mode the keypresses on your keyboard are interpreted as instructions/commands to vi, and different keys are used for different commands.

For example: in insert mode pressing x on your keyboard will put the letter x into the text where the cursor is, but in command mode pressing x on your keyboard will delete the character underneath the cursor.

Often times this creates such confusion (especially if you don't look at the screen when you're typing) that you have to abandon what you've been trying to do and start over. A good portion of this lab is spent on recovery from mistakes.

Quit without saving

Let's simulate a common scenario:

  • run+quit vi. no :w filename
  • command mode, insert mode
  • commands:
    • i
    • a
    • u
    • x
    • /
    • w
    • wq
    • q!

First half of the course: review