Prerequisites.
See the lab guide for information about physical and login access to the lab.
Security
Make sure that you log out again whenever you are done with a machine. If you are seated at a lab machine, there is a logout option on the “System” menu. If you are logged in remotely via ssh, then use the "exit" or "logout" commands.
Exercises
While at a computer in the lab, open a terminal window. There may be an icon in the task bar at the top that you can click to do this, or you should be able to find it in the menus at “Applications->Accessories”. All the commands in these exercises should be typed in this command window.
Identify your current directory with the command
pwd, which displays the “current working directory” of the shell process. This is the directory used for allrelative file names. Now make a subdirectory namedcs2023for this course using themkdircommand. Change the shell's current directory to this new directory using thecdcommand. Now create a new subdirectory for this tutorial calledtutorial1and change to that directory. Identify the current directory usingpwd. Run this command again, directing its results to a text file namedques2.txtwith the commandpwd > ques2.txt.Identify the system that you are on by typing the command
uname -ain the command window. Rerun this command directing the output to ques3.txt.Make a subdirectory of
cs2023/tutorial1namedques4and change to that directory.Copy the file
/fcs/courses/cs2023/tutorial1/hello.cto this directory. Examine the file usingcat hello.c. Also examine the file using “less”. You get out of less using the one letter command “q” (for “quit”).Compile this “C” program using “cc hello.c”. Examine the result with “ls”. Note that the file “a.out” was created. Run the resulting file with “./a.out”. Run this again, directing it's output to the file ques4.txt in this directory.
Change to the parent directory (“..”) and make a new directory
ques5. Then change to the new directory.Choose a text editor. The requirement is that the editor produce standard Unix text files, i.e. lines of ASCII text, each ended by the Unix “new line” character (technically ASCII LF, also called “line feed”). Some possible editors that run in a command line and therefore are useable via “ssh” are “vi” and “emacs”. Because you are presently at the console keyboard and display of a lab Linux machine, you could also use the Gnome text editor gedit, available from the menus at “Applications->Accessories->Text Editor”.
Create a single C source file (in the
ques5subdirectory) containing the example dweight2.c from page 23 of the course text.Compile and run this program
Make a tar file of the
ques5directory.Rename the
ques5directory toques5.bakusing themvcommand. Check the man page usingman mvif you need a hint.Extract your tarfile to recreate the
ques5directory