To gain
some experience and understanding of
1. A multiuser computer (loki)
2. Unix, an operating system other than
Microsoft Windows or MacOS
3. The Unix interface called Command Line
Interface or CLI ( shell , specifically bash )
4. To understand the difference between
local and remote computing
See this Lab as a scientific experiment where your tools are the computer, the software and the commands and you are the scientist who analyses, tests and observes the experiment. In this spirit you will produce two documents: a Lab Notebook (a Word file where you write your observations while going through the Labs), and a Lab Report (a Word file where you write your answer questions regarding this Lab).
During this entire Lab Meeting record in your Lab Notebook the name and purpose of any program that you use. This includes commands typed at the command line (since they are actually programs) and any icons that you click (since this also runs a program).
You can write any observation in your Notebook that you may find interesting while going through your experiment, however in the lab you will be asked to record some specific actions. Those requests are underlined. You are free to take pictures of your screen (use Ctrl+Alt+PrintScrn) and add them to your Lab Notebook with you comments.
After completing the Lab Experiment, answer the questions in the Lab Report file.
Return a printed hard copy of both the Lab Notebook and the Lab Report to your Instructor asap but not later than the beginning of next Lab meeting.
NO LATE LAB WILL BE ACCEPTED for this Lab!
For the
purposes of this lab, the computer that you are sitting in front of will be
referred to as the local computer. In this lab you are going to use the local
computer to connect to and then work on a remote computer. This remote machine
is called loki. It's full Internet address is loki.cs.kent.edu.
Computers
and operating systems that support many users at the same time are called multiuser
systems. Since many people can use them at the same time each user has a
separate account, identified by a username.
Each of
you have your own account on the remote computer loki.
Look up your username at loki usernames
Your
account will be protected from unauthorized access and use by way of a
password. There is an initial default password which you will later change.
Computers
used to be extremely large and expensive, and they produced great amounts of
heat. So much heat was produced that they were put in their own large,
air-conditioned rooms.
People
would work at a station called a terminal.
A terminal is a combination of a keyboard and a monitor. Out of the back of the
terminal would be a long wire that would directly plug into a port on the
computer (in the large, air-conditioned, room). The monitor could only display
characters/text, and the only input device was a keyboard, so people would use
a Command Line Interface
(CLI) to interact with the computer. Thus
named because one typed commands on a single line.
Not many
people use a terminal anymore to do any useful work at the computer. In general
they sit at a local computer and use it to work on a remote computer over a
network.
A shell
is a piece of software which provides a user interface to the computer's
operating system, so that we may enter commands. There are many ways of
accessing the shell on a remote computer from a local computer, including two
programs called telnet
and ssh.
The remote computer would run telnet and/or ssh
server software, and the local computer would run a telnet and/or ssh
client software. We interact with the telnet client
software on our local computer and it sends requests to the corresponding server
software on the remote computer. Most multiuser computers run one of these
server programs so that users can connect and use the machine.
As an
aside, you have probably used and have on your home computer several other
pieces of client software. You use an email client program (Outlook Express, Mozilla Thunderbird, Netscape's email client) to access
an email server to retrieve and send mail. Your web browser contains a web
client which makes requests for html and other documents from a web server.
The shell
access client software (the one running on your local computer) gives you a
terminal window
that along with a keyboard behaves the same as the old monitors used in the
original terminals.
Shell
access, such as through the ssh or telnet program
is a simple and low-bandwidth way of connecting to a remote
computer. Low-bandwidth means that only a small amount of information is
transferred per second. It doesn't require a fast connection to the remote
computer, and a client program can be run from any computer that is connected
to a network, even if both computer are using
different Graphical User Interface's (Windows, MAC
OS, X-Windows etc.) or not using a GUI at all.
Although
we discussed two ways of shell access to a remote computer, telnet and ssh
we are only going to use ssh.
When you
enter an account password using telnet the password is sent over the network in
cleartext. Cleartext means
that anybody that was monitoring the network connection would be able to read
it if they wanted to. If your local machine is not close, network wise, to the
remote machine, somebody at a machine along the way could get your password.
This is
such a problem that typically the root
( a special account with the highest level of
privileges on Linux/UNIX systems) is set up so that you can't use telnet to log
into it.
A
replacement for telnet is ssh,
which stands for secure
shell. ssh
doesn't send your information, including your password, in cleartext.
ssh takes the cleartext information, applies encryption to protect it,
sends it over the network, and decrypts it on the remote computer back to cleartext.
ssh is a replacement for telnet. If you
have a choice always choose ssh.
You are
going to use an ssh
client program from the local computer in front of you to access your account
on the remote computer loki.
Record the
steps that you take following these instructions. Include what you saw and what
you typed in. If you had to repeat a step note this in
your Lab Notebook.
To use ssh from MS Windows in the Lab:
Start
the ssh client program.
Open Program--> Accessories --> Internet Tools --> SSH Secure Shell Client.
To login you must have an account name. Look up your account name (username) in the loki usernames list. If your name is not in the list tell your lab instructor.
Choose Quick Connect from the menu bar and enter the host computer name and the account name (replace YOUR_USER_NAME below with your username from the loki username list).
For the host name
enter:
loki.cs.kent.edu
For the username enter:
YOUR_USER_NAME
then STOP and read the next paragraph BEFORE INSERTING ANY PASSWORD.
Call your instructor and enter the password with his help. Type the password carefully since if you make 3 wrong attempts you account will be locked. The lab instructor will need to contact the CS1 coordinator who will need to contact the system staff (at Kent!!) to get your account unlocked. This will take a couple of days to perform this operation. Do not allow this to happen and insert the password for the first time ONLY in presence of your instructor to avoid possible stalls. The instructor knows your initial password. Later in the lab you will change it, and it is YOUR responsibility to remember your password. Your initial password is the concatenation of the initial of your first name, followed by the initial of your last name, followed by the last 6 digits of your ID Banner.
If you have already used your account on loki, you have also changed the password. In that case you are the only person who knows the password.
At this point you should be connected to loki and on your account.
Note: You may download a free Windows compatible version of the SSH client program here SSHSecureShellClient-3.2.9.exe . Just click on the link Local Copy or Official Mirror Copy and Save the file on your machine. Once downloaded, the file may be installed by double-clicking on the name or icon. Once installed on a PC, this program will allow you to access your loki account over the internet.
Similar programs that support SSH are CoreLite, and PuTTY, which can be freely downloaded. Just click on their link.
When you
get access to an account for the first time on of your first tasks is to change
your password. Start
thinking of a password now that you can remember. The password must be at least
6 characters long and include at least one digit. Of course, don't write it
down in your lab notebook, but keep it in a safe place and don't let anybody else know what it is.
To change
your password, at the prompt type:
passwd
and press
the Enter key. The system may be slow to respond at times. Wait for it to
prompt you and follow instructions. Pick something you
won't forget that has at least one digit or uppercase character in it. If the
password does not meet the current security guidelines, you will be asked to
enter a different one. When you enter your password, it will not appear on the
screen.
Your password can be changed any time you want. However if you forget your password you need to contact the system staff (at Kent!!!) through your Lab instructor and CSI coordinator to get it fixed. This takes almost 2 days!!!! so...Do write down your password in a safe place (NOT in the Notebook!). Do not give your password to anyone.
Leave this
window open for the rest of the lab. We will get back to this window again.
However you must remember to logout at the end of this lab to avoid that other
people can have access to your data.
The
machine loki (loki.cs.kent.edu) is
a PC running the linux
operating system. The linux
operating system is the newest member of the family of UNIX operating systems.
The
different versions of the UNIX operating system were created by many different
companies, such as AT&T, IBM, and Sun, running on many different kinds of
computers from embedded computers (computers embedded in other devices) to
mainframes. The majority of computers that form the backbone of the Internet
are running some form of the UNIX operating system.
The core
program of an UNIX operating systems is called the
kernel. The linux
kernel was originally written by Linus Torvalds when he wanted to use UNIX on his PC.
The linux
operating system is an open source
project. Essentially this means that all of the source code (the computer code
written in a high-level language) is available to anyone who wants to use it.
Companies and people can take it and extend it as long as they make their
extensions also available. In fact, most of the software running on loki
is open-source. At this point many companies, such as IBM, contribute source
code to linux, All of it is available for free.
Installing
and configuring the linux kernel is not particularly
easy due to how flexible and powerful it is. To make linux
easier to install commercial companies have come up with linux distributions that
include the kernel and other software. Examples include CentOS, RedHat,
Debian, and Mandrake. The linux
distribution used on loki is Red Hat Enterprise 3. These distributions are also freely available
for download from these companies. However people often buy one of these linux distributions because of the convenience, manuals,
and support. A linux distribution on a CD can be
copied and distributed freely.
The linux kernel is only part of what an operating system
needs. Utility programs, graphical user interfaces,
development environments and even application software is also needed.
Much of the basic utilities that can be used with Linux are provided by the GNU Project, and the rest of the needed software
is provided by other open-source projects. This combination of the linux
kernel and supporting software is referred to as GNU/Linux, however
many people just call it linux.
The ideas
of open source software seem mysterious to some people. They don't understand
why people or companies would give away their source code and not charge for
their product. One of the best introductions to these ideas is The
Cathedral and the Bazaar.
The
program ssh provides you a terminal
window to a remote machine. This terminal window give you access to a shell
program which provides a CLI
(Command Line Interface). This shell program provides a user
interface to the operating system, in which you use the keyboard to type in
commands and view things using a text display.
The shell
gives you a prompt and waits for you to enter a command. After you enter a
command it carries it out and then returns to a prompt again.
There are
many advantages to using a shell. The shell commands allow more options and are
more sophisticated than using a windowing system. The shell commands,
especially complicated ones, can be entered more quickly. Also long series of
complicated shell commands can be easily automated.
People who
work at setting up and maintaining computer systems often use a shell to do
their work.
Here are
just some of the commands that the shell on loki
will let you use. Type in each command and record the command and what you
observed. Each command is actually a program. Show your activity by copying the
data in the notes (or by taking a screenshot of the window)
whoami
see who you are logged in as
who
see who's logged in to the computer
w
see who's logged and what their doing
uptime
shows various information including how long the system has been
up and the load average
quota -v
view your disk usage.
This command may not work correctly. Just write down what you observe when you
use it.
Enter the
command to see who else is on. Record the command that you used and the
usernames of at least 3 other users.
The program ssh provides you a terminal window to a remote machine that can be used to transfer files from your local machine to a remote machine (e.g. loki) and vice versa. The SSH File Transfer Client window is the GUI (Graphical User Interface) terminal window for the file transfer.
Open
Program--> Accessories --> Internet Tools --> SSH File Transfer Client (on
other machines, such as the one at your home, this program can be located in a
different directory. Use the Search to locate it).
Click on Quick
Connect and connect to loki.cs.kent.edu.
Insert your
password and click Connect.
The SSH File Transfer Client window is split in two parts: the right hand side half-window displays the content of the remote machine (i.e. loki) while the left hand side half-window displays the content of your local machine. When you connect to the remote machine, you will see that he right hand side half-window turns from gray (incative) to white (active).
You can view each single folder of your local machine as well as those of the remote machine. Practice a file transfer from your local laptop to loki. Just drag the file from the left hand side of the window and drop it on the right hand side. The file will not be removed from your local machine, but a copy will be made on the remote machine. When files are on loki, you can access them from any place as long as you have an SSH program to access remotely the loki machine. Record in your Notebook a snapshot of the SSH window after the file transfer.
Managing Files
For this
section you will need both a terminal window to enter CLI commands in, and the
SSH Secure File Transfer to see the content of the File Manager. You will go
back and forth between one and the other.
File Information
Data is
organized on computer systems into files. We use applications to create things
such as research papers, email, web pages, Lab Reports, etc. that are stored as
files. Much of the work that we do at the computer has to do with manipulating
files.
With your
terminal window, type in the following commands and record what you find in
your Lab Notebook:
ls
list the files in the current directory
ls
-a
list all the files in the current
directory
ls
-al
list all files in "long" format,
show additional information
Now look
at your files using the file manager SSH Secure File Transfer. Press the blue
chasing arrows from the menu on the remote side to refresh the screen. You can
get a detailed view of your files by clicking on the folder to open a folder
and then using the folder with the back arrow from the menu to move downward
and upward, respectively, in the hierarchy of the folders.
Deleting and Creating
Files
Use an editor, such as Text Editor available in the menu such as Wordpad or Notepad (under Program--> Accessories) and create a text file on your local machine. In the file write the list of the courses that you are taking this semester. Save the file with the name "MyCourses.txt".
Locate the file under the SSH File Transfer Client window in the local machine (if you do not see your file, look for the chasing arrows in the Toolbar of the SSH File Transfer Client to refresh the window) and transfer the file remotely by dragging the file from the left hand side of the window to the right hand side of the window.
You will
see that the file is now on loki.
Go to the
SSH Secure Shell and use the command ls
to check that the file is effectively there. (Be sure to be in the correct
folder where you have transferred your file, otherwise use the command cd to go up or down in the hierarchy
until you locate yourself in the correct folder. If you do not know how to
proceed, ask your instructor).
Record in
your Lab Notebook whether the SSH Secure Shell shows this file being created.
If we want
to remove a file we can use the command:
rm MyCourses.txt
deletes the file "MyCourses.txt"
Type in
the command and then use the command ls
to see if it is there.
Go back to
the SSH Secure File Transfer and refresh the screen with the blue chasing
arrows.
Record
in your Lab Notebook if the file manager shows this file any longer.
Files can
also be deleted/removed by being in the SSH Secure File Transfer by selecting
them and pressing the cross in the top menu.
Directories
Files are
organized into directories. A directory in the CLI corresponds to a folder in
the graphical user interface. This allows related files to be grouped together
which makes them easier to organize for our use and for security.
In the
CLI, to reach a file's location it is necessary to know what directory/folder
it is in, and what directory that directory is in. and so on and so on. This is
called the path to the file.
At any
point in order to figure out the path to the directory we are in we can use the
command:
pwd
"print working directory", shows the directory you are
currently in.
In the
file manager of the SSH Secure File Transfer the working directory is shown at
the top in the menu.
Creating a Directory
To create
a directory we can use the command:
mkdir CS1
create a directory named CS1 in the current
directory.
Since you
are hopefully in your home directory (you can use the command pwd to check) this will create a directory named CS1 in
your home directory.
Note that
file and directory names do not include any spaces.
To see
what happened, use the command ls
to see if the directory was created.
Record in
your Lab Notebook whether the directory created is seen there also.
Now we
want to work in the CS1 directory. The easiest way to do that is to change our
current directory to the CS 1 directory
You can
use the following command to do that:
cd
CS1
Use the
command pwd to check that you are in the right
directory.
Record in
your Lab Notebook whether the file manager of the SSH Secure File Transfer
changed to the subdirectory also. If not, double click on the name of the
directory to go in.
Record
in your Lab Notebook the file path that appears in the Location text-field of
the SSH Secure File Transfer in the top menu.
Go back to
the SSH Secure Shell. For demonstration purposes we would like to create a file
in this subdirectory. We can use the following command to do that:
touch anewfile
creates an empty file called "anewfile"
Record in
your Lab Notebook what is in the directory by using the command to see what the touch command did. Also check the file manager SSH Secure File Transfer to
see if it is there.
Moving out of a
Directory
In each
directory there are always two special files. One has the name "."
(yes, a single period) that is the current directory.
The other has the name ".." (yes, two
periods immediately after each other) that is the parent directory.
Before we
show this, Go back to the SSH Secure Shell and record in your Lab Notebook the
directory that you are in by using the command
pwd
Now we
want to move out of the subdirectory CS1 and back to our home directory. We can
do this by using the command:
cd ..
".." denotes the parent of the current
directory, the directory the current directory is in.
Now record
in your Lab Notebook the directory that you are now in by using the command. Also, use an command to get your bearings.
Record in
your Lab Notebook whether the file manager of the SSH Secure File Transfer
changed its current directory. If not, you can move back up by clicking the
folder with the back arrow in the top menu.
Home Directory
Shortcuts
Return to
the SSH Secure Shell. You can move directly to your home directory, no matter
where you are at, by using the command:
cd
changes to your home directory.
You can
also directly move to another accounts home directory. For example, we can move
to the account llaguer0 home directory by using the command:
cd
~llaguer0
changes to the home directory of llaguer0
.
Change to the home directory of llaguer0 by using the command shown above. Record the path of their home directory by using the command
pwd
Record in
your Lab Notebook what a person using another account would have to enter to
move directly to your home directory.
Now move
back to your home directory.
cd
An Example
Open Notepad on your local machine and type the following lines of code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello!" << endl;
cout << "Welcome to my class!" << endl;
return 0;
}
Save the file as hello.cpp. Now transfer the file from your local machine on loki using the SSH Secure File Transfer. Go back to your SSH Secure Shell terminal window and check the content of the file by using the command:
more hello.cpp
You will view the content of hello.cpp
This file
is actually a program written in the C++ language. We can compile the program
by using the command:
g++ hello.cpp -o hello
The command uses the program (compiler) g++ to compile
the C++ program file hello.cpp in the the executable
program called 'hello'. The executable program will be created in the current directory.
Check what
files were created by using the command ls. You can also refresh the file manager of the SSH Secure File Transfer window to see the file presence (the refresh button has 2 arrows chasing each other). Record in your Lab
Notebook the size of the files
hello.cpp
and
hello
This is a
program that can be run by using the command:
./hello
run the program in the file hello in the
current directory.
Record in
your Lab Notebook what the program did when it was run.
When you
are done working on your account you need to make sure to logout. The command logout will do this.
It is
important to always logout when we are done. If not, other people can get
access to our accounts. Not only can they steal or alter the information that
we have stored there, they can use the account to send threatening email, try
to break into other systems, etc.
Congratulations! You have just completed your first Lab Experiment. Return your printed Notebook to your Instructor. Now complete the Lab Report at this time and return it to your instructor asap but not later than the beginning of next Lab meeting.