CS 1440 Lab 1

Cover sheetPrevious ActivityNext Activity

Activity 1-2: Unix Basics

Activity Goals

Activity Procedure

Remember that Unix command lines are "imperative sentences". The UNIX command names are single words, and they function in the command line the way verbs do in English sentences. Just as some English verbs require objects, some Unix commands require additional information that is supplied as words (we call them “arguments”) following the command name.  Below are introductions to 6 important UNIX commands.



pwd is short for Print Working Directory.  Go ahead and give UNIX the pwd command.  You should see UNIX respond with something like  /u/css/an00678   but it will be your login not Alfred Newman’s.  This tells you where you are in the directory structure. 



ls is short for LiSt the files in the current working directory.  Go ahead and give UNIX the ls command.  You should see UNIX respond with a list of the files created for you by the system administrator.  Notice that one of them should be a file named 1440.  This is a directory dedicated for all the work you do for this class. 



cd is short for Change Directory.  This command requires one additional argument – the directory you want to change to.  Go ahead and try it out by typing the following:
                        %  cd  1440

Notice that UNIX does not have a response to this command (unless you did something wrong).  This usually means that UNIX has successfully completed your command.  But you can use the “pwd” command to verify this.  Make sure you really changed directories. 



mkdir is short for MaKe DIRectory.  This command requires one additional argument – the name of the directory you want to create.  Make sure you are in your 1440 directory, then make a directory for Lab1 by typing:
                        %  mkdir  Lab1

Again, UNIX does not respond if everything is okay.  You can make sure it worked by listing the files using the ls command.  You should see the Lab1 directory you just created.




cp is short for CoPy.  This command requires two arguments: the file you want to copy and the name of the new file (the copy).  You can make a copy in the same directory you are working in or in another directory.  You can also copy from some other directory.  Change directory to your Lab1 directory (cd Lab1) and let’s try several copy commands:
                        %  cp  /u/css/1440/Lab1/hello.C  hello.C

Use the ls command to list your files and see the hello.C file that you copied here from the other location.  Now let’s make a backup copy of this file:
          %  cp  hello.C  hello.bkup

Use the ls command to see your two files.




mv is short for MoVe.  This command moves a file from one location to another.  If the directory is the same for the moved file, this acts like a “rename” command.  Try this:
          %  mv  hello.bkup  hello.C.bkup

Use the ls command to see what happened.


Activity Followup

This is just the tip of the “UNIX iceberg.”  There are many more commands and many more options to the commands you learned above.  Here are some variations of the commands above you should know.  Try them out and see (using ls and pwd) if you can figure out what they do.

q       %  cd

q       %  cd  1440/Lab1

q       %  cd  ..

q       %  ls  -CF

q       %  ls  -al

q       %  ls  ..

q       %  ls  .


It is often instructive to see what happens when something goes “wrong” so let’s try a few wrong things!

q       %  cd

q       %  cd  Lab1        (this is “wrong”)

q       %  cd  1440/Lab1

q       %  cp  hello.C     (this is “wrong”)