Lab 8 Using vi Editor

Sequence 1: Navigating with vi

  1. Log in as user student

[student@stationX ~]$ cp /etc/passwd ~

[student@stationX ~]$ vim ~/passwd

  1. First, try moving around using such as the arrows, PgUp, PgDn. They should all work as expected. Note, however, that on older systems they might not. moving from word to word with the w and b keys. moving by sentence (the parentheses) and paragraph (the curly braces)
  2. Try combining numbers with movement keys.

5w

2Down Arrow

7. Press the i key.

The arrow keys, Home and End still move your cursor

  1. Exit insert mode by pressing Esc.
  2. Try pressing the u key. This will undo each change that you made. Changes can be re-done with Ctrl-r
  3. The ex mode is invoked by typing : while in command mode.
  4. At the ex prompt (:) enter set nu.
  5. Try entering ex mode again and typing :set nonu.
  6. Try jumping to line 5 by typing 5G.

G to the end

1G to the first line

  1. Search feature: /root.

press n and N to navigate.

:set nohls.

:set hls.

  1. Try running :q. :q!

Sequence 2: Configuring vim

[student@stationX ~]$ vim ~/.vimrc

:set nu

:set wrapmargin=10

[student@stationX ~]$vim /etc/passwd again.

Sequence 3: Configuring basic sudo privileges with vim

[student@stationX ~]$ su –

[root@stationX ~]# visudo

/root

The line appears about halfway down the file and looks like this:

root ALL=(ALL) ALL

yyp

yy “yanks” (copies) the current line and p “pastes” it one line down.

cw studen Esc.

w cw stationX

The line should now read:

student stationX=(ALL) ALL

7. Exit insert mode by pressing Esc. :wq

[student@stationX ~]$ ls /etc/pki/CA

ls: /etc/pki/CA: Permission denied

[student@stationX ~]$ sudo ls /etc/pki/CA

Password:

private

sudo will remember that you have already authenticated for five minutes before prompting you again.

Challenge Sequence 4: Learning more with vimtutor

[student@stationX ~]$ vimtutor

By |2015-01-01T01:43:48+00:00January 1st, 2015|Linux and Unix, Linux/Unix Basics|0 Comments

About the Author:

Leave A Comment

Show Buttons
Hide Buttons