Unix and the ElementK Virtual Machine
- Unix Lab Hints
- ElementK Unix Virtual Machine
- Optional
Unix Lab Hints
These are just some hints for the labs; these are not directions for any
individual lab but, if you get stuck whilst doing a lab, please do refer
to this guide of hints for a solution first.
- [Using the Linux VM on ElementK/iLab and Eclipse on Citrix] vs. [rolling your own]:
-
For the first two weeks, we will be using the ElementK Linux Virtual Machine for the
UNIX/Linux labs. I would recommend using ElementK since installing
your own distro of Linux could get complicated and we will not be doing any
programming that requires compilation in this part of the
course.
-
For the second part of the course (weeks 3-7), when we get into
Java, we will use Citrix to access the Eclipse IDE. If you feel
adventurous, you could also
setup your own IDE development environment such as Eclipse,
NetBeans, or the regular JDK to
develop your programs on your own PC.
-
Using your own: In principle, you may use your own computer to
complete the labs in this course. However, keep in mind, you would
need to install a Linux distro for the first part and, for the
second part, you would need to
install the Java SDK and an IDE such as Eclipse.
You will be on your own without
support for any installation problems as well as for any
troubleshooting problems. In
addition, you need to provide the reports (e.g. source files and
screenshots) in MS Word
format regardless. Installing your own distro and/or Java
development environment is certainly an excellent pedagogical
tool but ONLY if you are willing
to do your own support.
- Log into elementK first:
- url: http://knowledge.elementk.com/
- username: D# (with capital D)
- password: year and month of your birthday (in the YYYYMM format) for Students and hire date for Instructors
- Launch the Unix Virtual Machine/PC (it's a RHEL VM). Detailed Login
Instructions are provided here but an overview is also
given directly below:
- Deliverables/To Hand In:
- There is a word document template in
Doc Sharing
to document
the results (or partial results for long displays) for each command
you execute; this file is called Lab_report_wk1.docx
.
- You don't need to type the complete results of the
commands. Just enough to show me you executed the commands. If you
can provide the same information using screen captures, that will
be fine also.
- Getting the output: One way is to take a screen-shot of the
output by using your system's PRINT_SCREEN function.
- For Example, for
Windoze systems, you might be able to do this by selecting the output window and pressing the
ALT and PRT SCRN buttons; this will place a copy of the screen in
the clipboard and you can paste it into a Word document using
Word's paste command.
- Another way is to use the
script
command in Linux.
-
Nota Bene: Please be careful of the following common Linux traps:
- Case is very important in Linux/Unix so please check
the syntax and spelling if the shell interpreter gives you errors.
Also, please note that it's sometimes hard to distinguish between a
lower-case L ("ell") and the number 1; e.g.,
ls -l
is
LS -L
(listed in upper-case to make the difference clear;
actual commands are in lower-case), not 1s -1
.
- Be very careful of spaces in your commands and paths. Paths
rarely have spaces in them (at least when they're not escaped)
and commands often need spaces in strategic points. So if a command is
not working for you, please check the the spaces, in addition to the
case and correct letter/symbol.
- Also, when you're given a prompt as
#
or $
or %
or >
, please remember that you don't have to type the
prompt; the prompt is what you should see in the Unix shell as where you start typing your commands.
Lab-specific Hints
- For part 1 of Lab 1: The
Texas.txt
and
fortunes.txt
files under /root/Desktop
have DOS-style CRLF line terminators, so finding text at the end of
the line using grep
might not work. You can use the
dos2unix
or dtox
commands to convert the line endings before
doing the exercise, if you like. E.g.,
dtox msdosFormattedTextFile.txt > unixFormattedTextFile.txt
or
dos2unix msdosFormattedTextFile.txt > unixFormattedTextFile.txt
or, for newer versions of dos2unix
, you might need to use:
dos2unix -n msdosFormattedTextFile.txt unixFormattedTextFile.txt
- Nota Bene, if you're having difficulty finding these files,
please do use the
find
command, as detailed just below
here.
- For part 2 of Lab 1: The goal of part 2 is to help you learn how
to navigate using shell commands in a Linux/Unix system. To do this
you have to understand the Linux file system, how to type Linux
paths, how to use the
cd
command (change directory
command), how to use the ls
command (list file
command), and how to use the more
command among many others. Things to
remember include:
If you have never used the Command Line Interface (CLI) before, it will be a little
frustrating at first as it's different from a Graphical User Interface
(GUI). Ask questions as you go along and we'll all fill in the blanks for you!
- Deliverables for Lab 1: you should submit a single Word .doc/.docx file that contains:
- Part 1: The commands with results for Part 1 (using the template in DocSharing)
- Part 2: The location of Texas.txt along with your favourite line from that file
- Part 3: List the commands you found in the "Who's on what?" story
- For Part 3 of Lab 2:
- Create and run
hello.c
(questions to answer for yourself: what is
hello.c
? How do you create an executable version of it? How do you
actually run the executable version in the shell?).
- Create and run
hello2.c
(I'd answer the same questions for this part
as the previous one; namely: what is hello2.c
? How do you create an
executable version of it? How do you actually run the executable version
in the shell?).
- Use shell redirection to provide input and control output.
That's all that's required for this part of the simple C++ compilation/execution under Linux section of the lab.
ElementK/iLab Unix Virtual Machine Detailed Login Info
Quick instructions on how to log into the elementK/iLab Unix Virtual Machine.
Nota Bene: if you wait till the weekend to do the lab, please be
aware that you might experience significant performance degradation as a
lot of students in other classes put off the lab until the last minute
and the load on the Virtual Machine server increases exponentially over
the weekend, as compared to during the week.
-
Log into ElementK/iLab first: http://knowledge.elementk.com/.
You'll see the following screen:
where you can login with your D-number and Birthdate (Hire date for instructors).
-
Once logged in, please go to the
Catalog
in order to launch
the Unix Virtual Machine:
You may choose any of the Comp328 Labs in order to get to the Unix Virtual Machine.
-
At the next screen, please click the
Lab Content
tab and you'll see the screen below:
Next, please click the Access vLab
button to launch the lab.
-
Next, you should see the login screen:
Here, you have to enter the lab reviewer
email. You may
enter any email you like here and then click Next
.
-
At this point, you should see the screen below:
Now you're ready to click the START LAB NOW
button.
-
Your lab will now start to initialize:
Next, you'll see the image of a computer with the phrase
Click on the diagram to start your Virtual Lab experience.
Click the diagram and a new window should open up.
-
This new window will contain your new Unix Virtual Machine:
You can log into this Unix Virtual Machine with the username root
and password password
.
OPTIONAL
Miscellaneous
A sample BASH shell script:
#!/bin/sh
dir=$HOME/bankstatements/`date +'%Y%m%d'`
for x in grep -l "Bank Statement" $HOME/incoming/a*; do
mkdir -p $dir
mv $x $dir
done
Optional
Please note: This part is completely optional.
Please find below, the format necessary to access ElementK's FTP
resources. Please note that this login varies from the format used to
access ElementK's vLabs (https://knowledge.elementk.com/).
- OPTIONAL: FTP'ing data to and from the RHEL VM.
- You can do this from the RHEL VM or from your Windows/Mac Desktop:
- FTP root address: ftp://materials2.elementk.com/
- User Name field requirements: Students D# (including the "D" in the beginning)
- Password field requirements: This is the users entire last name with
the first letter being capital, the ampersand (&), and then the last
four digits of the students D#
See the example below for a fictional user with a D# of D01234567 and a last name of "Lastname":
If your last name has less than three characters, there will be
a slight, non-standard variation from the format above. In this case,
please contact the Help Desk at (877) 784-1997 and open a ticket so
that they may send your ElementK FTP login info directly to you via
email.
- Steps to FTP from RHEL VM to the ElementK Knowledge HUB:
In the command line mode, enter
gdm
Once the
GUI comes up, enter
root
for user and
password
for password
Open the
gftp
application and enter:
- Host:
materials2.elementk.com
- Port:
21
- UserID: Knowledge Hub User ID
- Password: Your Last name followed by the & symbol followed by
the last four digits of KnowledgeHub user id. E.g., if your
KnowledgeHub user id is
D889977
and your name is
Smith
, your password
would be Smith&9977
.
- Hit the
Enter
button on the keyboard after entering your UserID and Password.
- In the left hand pane, navigate to the folder where the file resides.
- Drag the desired files from the folder in the left hand pane to the ftp folder (right hand pane).
- Steps to FTP from ElmentK Knowledge HUB to your Windows/Mac Desktop:
- Once you have completed all the lab objectives, go to ftp://materials2.elementk.com. Then in Windows Explorer go to Page → Open FTP site in Windows Explorer. A window will pop up and then you can right click on your file and copy to your desktop.
Ricky J. Sethi, PhD <rickys@sethi.org>
Last updated: Friday, July 13 2012
(sethi.org/tutorials/tutorial-elementK_unix.shtml)