At the beginning of the lab period the instructor will cover the following aspects of using the lab facilities:
• the location of home directories on the server when logging in on the Apple Macintosh computers and
when logging in to a LINUX computer (e.g. tuxworld);
• how to start a virtual terminal on a Macintosh computer using the Terminal application in the
• how to start a remote login on tuxworld from a Macintosh computer (within a Terminal window);
• how to start a remote login or remote session on MacTS1 or MacTS3 from an on-campus machine.
Much of the information to be presented can be found at http://www.cs.usask.ca/support/index.php and then
expanding the “How to Access Your Files from Computer Science Lab Computers”, “Remove Access to
LINUX”, and “Remove Access to Apple Mac” items.
Perform each of the tasks below in a Terminal window on a Macintosh computer in the instructional
laboratory. For each task, copy-and-paste the contents of your virtual terminal window (including the
commands that you typed, as well as any output produced by the commands you gave) into a text file called
lab1.txt. However, do not include extraneous or superfluous commands or output; only include content
relevant and essential to the specified task. Unless otherwise specified, all commands should be run using
the bash shell. Then, with a text editor, add text and identifying information to clearly distinguish
which commands/output/code correspond to each task. Submit lab1.txt through moodle when
done. This lab is out of a total of 13 marks, with each question (1a, 1b, . . . , 3b) being worth one mark.
Questions 2b and 4 are also each worth one mark. Marks may be docked for extraneous, irrelevant, or
superfluous content. The submission is due at 11:55 p.m. on Thursday, September 15.
Remember to put your name, student number, and NSID at the beginning of lab1.txt. Make sure that
you submit a text file and not, for example, an RTF or MS Word file.
You cannot use the exec command to answer any of these questions (complete any of these tasks). If
you do not know what the exec command is, you can safely ignore it for now.
Note that, by default, Finder on Mac OS X does not show the existance files whose names start with
1. (a) Use a UNIX command to create directories called 214bin and 214lab1 under your home directory.
Both new directories should be subdirectories of your home directory.
(b) Download the file ls for this lab. (Note that, depending on what browser and operating system
you use, the name of the downloaded file might have a dot (period) appended to it; i.e., the
downloaded file might be called called “ls.” rather than “ls”.) Then use the UNIX mv command
to move the downloaded ls file to your new 214bin subdirectory. Make sure it is called ls in
the destination directory (e.g. does not include a trailing ‘.’ character). Finally, use the UNIX
with an appropriate argument to change the permissions of your newly-downloaded ls file so that
you can execute it. (Note that a “usage” message from the chmod command at this point might
indicate that the command given was incomplete; i.e. the intended operation was not performed.)
Assistance with the chmod can be found on pages 741-745 of the Sobell text (3rd edition) for the
You do not need a log of downloading ls in your lab1.txt file. A log of the other portions of
this question does need to be present, however.
(c) Change your current working directory to the 214lab1 directory created in step 1a.
(d) Without changing your current working directory from what it was in step 1c use a UNIX command to list the files in your home directory. Do not use any options in the chosen command.
This command should work no matter what your current working directory is.
Hint: consider using an environment variable.
(e) Use a UNIX command to alter your PATH environment variable such that the pathname for the
214bin directory that you created in step 1a is the first one in the list of directories. Make sure
to add to the list of directories, rather than replacing it. Assistance with performing this step can
be found on pages 132 and 308 of the Sobell text (3rd edition) for the class.
Note that you will need to use a pathname (for the 214bin directory) that does not depend on
the current working directory being any particular directory. For instance, the simple relative
pathname 214bin will only work if your current working directory is the parent of 214bin. The
setting of PATH should cause that directory to be search no matter what your current working
(f) Execute again the exact same command you used in step 1d.
(g) Use a UNIX command involving which to help explain the output of Step 1f. That is, use the
which command to determine the program that was executed when you gave the ls command in
(h) Use a UNIX command to output the contents of the downloaded file called ls (which you placed
in $HOME/214bin in step 1a) to the terminal.
At this point, you may wish to redefine your PATH environment variable (undoing the modification
made in step (d)). Alternatively, you can terminate your virtual terminal window, and create a new
one. You do not have to show this in your lab1.txt file.
2. This question assumes that students are not using tcsh as their login shell. If you are, then make sure
to backup any .tcshrc you have before performing this question, and restore the backed up version
(a) Use a UNIX command to start tcsh. Then use another UNIX command to exit from tcsh (so
that you are using your original login bash again).
(b) i. Devise a UNIX command that will simply output the string “You have started tcshrc” to the
ii. Using a text editor, create a file in your home directory called .tcshrc with the contents
consisting of precisely the command from part i. You do not need a log of this step in
lab1.txt. Make sure your new .tcshrc is in your home directory.
iii. Output the content of your .tcshrc file to the standard output (e.g. your virtual terminal
iv. Start tcsh (again).
v. Exit tcsh (so that you are using your original login bash again).
Depending on the text editor used to create the file in step ii, you may end up with a file having
carriage return characters delimiting lines rather than newline characters. This may cause unusual
or unexpected behaviour in this question. If you experience such behaviour, check for this problem.
3. (a) Use a UNIX command and standard output redirection to create a file called editor.txt containing a list of all the entries in the whatis database whose description contains the word “editor”.
(b) Issue a command to bash that will disable the overwriting of existing files when using standard
output redirection, and then repeat the command from step 3a. Make sure that editor.txt
already exists when you begin this task.
4. Determine the version of bash present on the lab Macintosh computer you are using. Do this by
invoking bash as a command with a suitable option.