Lecture 20 - UNIX 4


Home > Lectures > Lecture20

Objectives

Contents


The upcoming tutorial  is in the Unix Lab B1.11

1. The vi Editor

The vi (pronounced Vee I) editor is a character based, full screen, text editor. It uses its own set of commands (you can get a summary from here - it is printable postscript file which you must save to Unix and then print. In mozilla, right click on the link and select Save Link As..., click Ok to save the file, then print it).

Vi is a moded editor. This means that it operates in different modes. When you first start it, it is in command mode. Here you can give keystroke commands to move around the file, delete lines, copy, paste, and the like. When you give one of the text insertion commands, such as i, you move to insert mode where everything you type goes into the file. You leave insert mode by pressing the ESCAPE key, which returns you to command mode. There is also a bottom line mode which allows more complex search and replace operations. The commands are case sensitive e.g. a is different to A. Once you are familiar with the commands, vi is extremely quick to use, particularly if  if you are a touch typist.

vi has a number of advantages:

Some useful vi commands:

To run

Modes

Files

Moving Around

Editing Text

Exit

Note: When you complete an editing session, you save the file and exit using ZZ

2. The Pico Editor

pico is a basic full screen text editor that doesn't require a graphical environment to run. This can be useful if you are logging in from a system that doesn't have a graphical environment. pico uses special keystrokes to perform commands, such as Ctrl+X to exit, Ctrl+G for help. It doesn't use the mouse.

Some commands are shown at the bottom of the window. Many commands use the control key (Ctrl).

To Run

Files

Moving Around

Editing Text

Miscellaneous

Exit

3. Editors

Unix is an old system, which has been updated constantly. There are many available editors. Some include:

4. Executing (or Running) a Program

5. Unix Revision

The following files exist on a fictional Unix computer:

     /usr/home/student/absurnam/ass2.java
     /usr/local/pub/bitpen/bj.java
     /usr/local/pub/bitpen/unixcommands.html
     /usr/local/pub/bitpen/ball.gif
     /usr/local/pub/bitpen/ltub.gif
     /usr/local/pub/win95stuff/ws_ftp.zip
     /usr/local/pub/win95stuff/ws_ftp.txt
     /sbin/ps
     /sbin/ls
     /etc/passwd
     /etc/group

Draw a tree diagram showing all of the above files

Assuming your home directory is /usr/local/student/asur3, give the commands to perform the following sequence, updating your tree diagram as you go:

  1. Ensure your home directory is your current directory
  2. List the files in your home directory
  3. List the files in your parent directory
  4. List all of your files, including hidden files showing their permissions, size, etc.
  5. View the contents of the '/etc/passwd' file
  6. How can you find out what Unix group you belong to?
  7. What group do you think you belong to?
  8. List the contents of the '/usr/local/pub/bitpen' directory, showing permissions etc.
  9. Display your present working directory name
  10. Create a new directory called 'mytmp' attached to your home directory
  11. Copy the passwd file into your new mytmp directory
  12. Change into your new mytmp directory
  13. Copy all files from /usr/local/pub/bitpen into your new mytmp directory
  14. Change the permissions of all the files in your mytmp directory so that only you and users in your group can read and write them (This will require two commands)
  15. Delete your new mytmp directory   (This will require a number of commands)

6. Discuss Assignment 3


Further Reading


Previous Lecture | Lecture Index | Next Lecture | Tutorial
Last modified 09-May-2005 by Tim Whitfort.
Copyright © 2003-2005 Brian Retallick & Tim Whitfort