Unix, Introduction and Concepts

Tom Kelliher, CS23

Feb. 9, 1996

From last time:

Determine the loop invariant for a function which finds the sum of the first five positive values in an integer array with n elements.

Starting with a function:

int sumFive(int array[], int n)
{  int count;   // # of positive elements found
   int i;       // loop counter
   int sum      // sum of positive elements

   // invariant: sum is the sum of the count positive values among
   // the elements array[0]...array[i-1].
   // 0 <= i < n, 0 <= count <= 5
   for (count = i = sum = 0; i < n && count < 5; i++)
      if (array[i] >= 0)
      {  count++;
         sum += array[i];
      }

   if (count == 5)
      return sum;
   else
      return -1;   // neat trick, right?
}

Unix

Unix RULZ!!!!!!!

Unix is easy to use but difficult to learn.

It is impossible to learn everything about Unix. Concentrate on what you need and what you think you will enjoy. Start by learning the basics. Then learn whatever you want, in whatever order you want.

Unix is a culture. Unix is a set of tools.

I hear, and I forget. I see, and I remember. I do, and I understand.

Common Trip-Ups

  1. The Delete key doesn't work
  2. The Ctrl and CapsLock keys are reversed
  3. There are suspended jobs.
  4. The path component separator
  5. The arrow keys and other cursor positioning keys
  6. Those ``funny'' keystroke sequences in emacs.
  7. Toggling between emacs and the shell.
  8. Forgetting your Unix text when you're working.

Anatomy of a Command

ls -aCF

ls -a -C -F kelliher/pub

ls -l ~

cat Class/Cs23/Hw/hw1.tex

w | grep burgerec

g++ -o homework1 homework1.cc library.cc

./homework1 > homework1.results

rm *

rm -i *

alias rm 'rm -i'

less .cshrc .login

Unix Concepts

  1. Your userid and group
  2. Your home directory
  3. The filesystem; navigation
  4. Filenames; wildcards, abbreviations
  5. File permissions
  6. The superuser
  7. Processes
  8. Environment and shell variables
  9. The shell
  10. .cshrc, .login, and .xinitrc

Hands-On Lab

  1. Login to the Novell network in the Math/CS Lab
  2. Use Netscape (IBM Webexplorer in the other labs) to find and print a copy of the homework
  3. Use the telnet tool to login to keystone
  4. Change your password (the passwd program)
  5. Try some things from Abrahams & Larson, such as the list of commands on pp. 22--23.


Thomas P. Kelliher
Thu Feb 8 14:26:53 EST 1996
Tom Kelliher