Lesson 1: Commands

This tutorial will help you learn the basics of Unix. You should work on it while you are at the computer. Read a paragraph, then try the suggested commands. Do they work as intended? If not, look back at the lesson, and think about what went wrong. It was no doubt a "typo. " Computers, unlike human beings, are rather stupid (even though very fast), and can knot undrstand things that R missspelled or otherwise gurbled.

Think of a computer as an obedient servant: we give it commands, it obeys. The goal of these lessons is to learn to "speak Unix", the language in which we shall command our servant.

Let us begin with a simple command: we want the computer to tell us today's date. Here is how to do it:

   % date
   Fri Mar 25 09:24:30 MST 1994

Wasn't that easy? Note that your commands --- what you tell the computer to do --- are displayed in bold. What the computer replies is displayed like this. Note also that you didn't type " % ": that is the prompt that the computer types. It does this when it is listening for your next command. (Prompts can be different from " % ")

Try the "date" command now.

Here are some more commands to try, with samples of how the computer might respond.

    % whoami
   jeremy

whoami displays the login name of the current user, who (for the purpose of these lessons) is "jeremy. " Try this now. The computer should respond with your login name.

   %  echo This is a test
   This is a test.

echo does just that: it tells the computer to retype the string "This is a test". Here is another use of echo:

   % echo $PRINTER
   b129lab1

This time echo tells us what is stored in the PRINTER variable --- the name of the printer the computer will use if you print something. Capitalization is important in Unix, so be sure to say "PRINTER", not " printer" or "Printer". The dollar sign in front of the variable name is also important. Note what happens if we forget to use it:

   % echo PRINTER
   PRINTER

Try all the examples above. Also: know where your printer is!

This is as good a time as any to introduce a little computer jargon. The words of the string "This is a test" are arguments to the command echo. The results of a command depend on what the arguments are.


Review

Write down on a sheet of paper the names of all the commands you have used in this lesson. Carry it around with for a few days, and use it to review the commands several times. Do this both at a workstation and away from it. Finally, explain to a coworker or fellow student what the commands do. Do this at a workstation so you both can try things out.


Back to tutorial | On to next lesson