Inhoud

Vi Editor Exercise 1

Preparation

WARNING:

  1. Copy the file /etc/passwd to your HOME-directory.
    Name your copy mypasswd
    Hint: your HOME-directory is the base directory for you as a user.

vi mypasswd

HINTS:

  1. Above the first line of this new file, add the line: This is just a test file!
    Hint: O (capital o)
  2. Add a new user to your test file.
    Hint: yyp
  3. See to it that the last line becomes the last line but one.
    Hint: ddp
  4. For the last 5 user accounts add the comment: UNIX user
    Hint: The comment field is the 5th field in the passwd file.
    Hint: Use the vi repeat command to make things painless.
  5. Make each line start with one TAB.
    Hint: Regular Expression characters ^ $
    Hint: :1,$s/ / /
  6. Try to undo your last change.
    Hint: u
  7. Use vi to copy all administrative users to a file called passwd.adm
    Hint: Administrative users are users like “root” and “lp”.
    This example shows how to copy lines to another file:
    "a5yy
    "b3yy
    ..
    ..
    :e passwd.adm
    "ap
    "bp
  8. Quit vi.
    Check if you have a file named .exrc in your HOME-directory. Make a backup copy of your existing .exrc
    Create the file $HOME/.exrc containing the following two lines:
    :set showmode
    :set list
  9. Use vi to reopen your test file and check which vi-options are available.
    Hint: :set all
  10. In your test file, pick one of the user accounts and use <space> to add a blank at the end of the login shell field.
    Is this blank visible?
    Which vi-option will make it visible?
    What do you think? Would it stll be possible to login with a blank after the shell in the real /etc/passwd?
    Remember this option! It's an invaluable option in debugging a non functioning config file!

.

Copyright (C) 2011 Integrated Services; Tux4u.nl
Author: Ing.J.M.Waldorp
vi-exercise1 20030514, 20110417