.nr PO 1i .nr LL 6.5i .nr PS 12 .nr VS 15 .SH .ce Introduction to UNIX and C .LP .ce J. Louie, August 1994 .PP This exercise is meant for new Sun computer system users, and for those who are not familiar with either the OpenWindows system or C-language programming. .in 0.4i .LP .ti -0.4i \f31.\f1 If you are not familiar with the Open Windows graphical interface or the UNIX operating system, go through the exercises in the Sun System Users's Guide. You will find all the Sun guides and manuals on a bookcase in room 320 LME. They are numbered sequentially on their spines or covers. The best book to start with is numbered 1. .PP Log in to any of the Sun workstations in room 320 LME. When you log in, you will first be prompted to select a window system. At first, type "\f3o\fP" for the OpenWindows system, and press the "\f3return\fP" key. Then you will enter the window system described in the guides. It may take up to 5 minutes to initialize, so be patient. Please change your password to something that no one could guess and cannot be found in a dictionary. Notice that the UNIX system distinguishes between upper and lower case letters, so be sure to type commands exactly as you read them. .LP Once you have mastered logging in and out, and have changed your password, try the Open Windows tutorial. When you are in the window system, point to the background, outside of any windows or icons. Then press and release the right-hand ("Menu") mouse button to see the Workspace menu. Move the pointer to the "Desktop Intro..." menu item and press and release the right button again. A hypertext document will appear with instructions to guide your through the features of the window system. After you have read this, the best way to learn how to use the system is to practice. .LP In the Sun System User's Guide, manual number 1, go through Chapts. 1, 2, 3, 4, 6, 7, and 8. Then go to the Sun Beginner's Guide for "Getting Started with UNIX," manual number 4, and follow the exercises in Chapts. 4, 5, 6, 7, 9, and 10. .LP Note that you can print a text file such as a program, shell script, or mail message with the command "\f3print\fP \f2filename\fP", where \f2filename\fP is the name of the file to print. Later you will use the "\f3lpr -Pmantle\fP \f2file\fP\f3.ps\fP" to print graphics files. Check the printer queue with the command "\f3lpq -Pmantle\fP". .LP There are at least three ways to edit text. The Sun System User's Guides have info on a mouse-based editor "textedit". The "vi" and "emacs" editors can be used on any workstation in a command window, or on a dumb terminal. "vi" is documented in the manuals, Solaris 1 binder number 13. The "emacs" editor includes a tutorial session. If you are not plotting graphics, you don't need to use a Sun workstation. To work on text or program code, or print files, you can log in to the Suns through any of the dumb terminals, PCs, or the Mac in room 320. Both troff (as "ptroff", see binder 13) and TeX (as "latex") are available for document formatting. This page was done with "ptroff", from a file created with "vi". .LP In your home directory the system administrator should have placed several programs to help train you in UNIX and C programming. The exercises below are based on these programs. If you cannot find them in your home directory, contact the system administrator. You can always contact the current administrator by sending e-mail to the user named "sysadmin". .LP .ti -0.4i \f32.\f1 Examine the C-language program "hello.c". Compile and execute it with: .IP % \f3cc -o hello hello.c\f1 .br % \f3hello\f1 .br % \f3rm hello\f1 (get rid of the big object file when you are done) .LP Manual number 89 in 320 LME is a C programming language reference manual. .LP .ti -0.4i \f33.\f1 Examine the C-shell script "hello.sh". Interpret and execute it with: .IP % \f3csh hello.sh .LP What does it do? .LP .ti -0.4i \f34.\f1 Edit "hello.c" with a text editor. Experiment with leaving out lines, one at a time, and then try to compile it. If there happen to be no errors in compiling, try to run it. .LP .ti -0.4i \f35.\f1 Examine and run the program "loop.c". Why would loops in C usually start at zero? Change the program so it actually counts to 10. Change it so it counts only even numbers. .LP .ti -0.4i \f36.\f1 Examine the C-shell script "loop.sh". Change it so it counts to 10 also. Remove its first line and see what happens when you "csh" it. .LP .ti -0.4i \f37.\f1 Be sure you are familiar with the on-line manual. Give the command "\f3man man\fP" and read carefully. Also try "\f3man -k man\fP" and "\f3man -k man | more\fP". .LP .ti -0.4i \f38.\f1 In the Open Windows interface on a Sun workstation, type the command "\f3viewmat par=/quake/s5/john/d.class/plslpar &\fP". The Viewmat tool will appear on the screen. Move its window so it is entirely visible and not obscured by other windows. Then select All Planes from the menu under the Show button. Wait a few minutes for rendering to complete, then use the slider labeled Plane to view the frames of a movie. Or select Refresh from the frame menu. The movie shows the propagation of an acoustic wave through a heterogeneous velocity model in cross section, synthesized by a finite-difference solution of the acoustic wave equation. When you are done with the Viewmat tool, select the Quit button. .LP .ti -0.4i \f39.\f1 Go through the tutorial introduction in \f2Kernighan and Ritchie\f1, completing the exercises along the way.