Welcome to
the CSE 314 UNIX Tutorial. If this is your first time using UNIX, you may
notice that this is not your average workstation. Although the UNIX environment
is much different from those of PCs, once you become familiar with UNIX you
will quickly become comfortable with your new workspace. This handout is
designed to orient you to that environment, and to provide you with the basic
commands for working on the UNIX system. Along with the on line help, this
should get you off to a good start working with, and even enjoying, UNIX.
The
computer facility you will be using is a distributed network of Sun Enterprise
450 servers with various thin clients. Thin clients are not independent computers,
but terminals, capable of graphics and sound. The machine sitting in front of
you is just a way for you to talk to an actual computer, with memory and the
processors that will run your programs.
Learning how to use the Sun
computing environment will take some time. Fortunately, there is a lot of
on-line help that will make this necessary process easy. First, you will need
to learn how to interact with the window system. The default window system
currently used by students is the X window system using the Common Desktop
Environment (CDE), a window manager and user environment that is found on most
commercial UNIX vendors' machines. In addition, you will have to learn the UNIX
operating system. Finally, you will have to learn to use an editor in order to
create and modify files, including program files. The recommended editor is XEmacs (although other editors, such as vi,
are also available).
A few of the basic concepts
behind our system may be unfamiliar to new users. An understanding of these
concepts is essential for completing your work efficiently.
The
computers in the CSE network are connected in a distributed network according
to the “thin-client/server model”. The thin-client/server model
describes the quality or type of interaction occurring in a distributed
network. One program, called a client, sends a request to another program,
called a server, which satisfies the request. Thin clients will run their
graphics and sound locally, but rely on the servers to tell them where to place
their windows, what colors to paint them, and what programs to display for the
user. Some of the terms that you'll hear in this environment might be
unfamiliar. We'll consider these now.
In general,
this is the machine sitting in front of you. Whether you're using a PC, Mac,
HP, Sun, or X terminal is irrelevant. The environment we provide you will treat
your desktop machine as an X terminal, capable only of displaying graphics and
sound.
These are
the computers to which you login. Although you're typing on a client, those
keystrokes are being sent to a login server, where they are interpreted, and
appropriate responses are formulated and returned to your client. Login servers
typically have many people using them at once; they are equipped with adequate
memory and processing power for all. What they do not have, however, is a lot
of local disk storage.
Login
servers need not have a lot of local disk, because file servers provide disk
space. People do not use file servers directly. They work on login servers, but
when they request a particular file, such as their mailboxes, these come from
an appropriate file server.
If you are
new to computers, the idea of a hierarchical file system may also be new to
you. This topic describes the basic components of the hierarchical file system.
A file is a
container that holds information. Most of the files you use contain information
(data) in some particular format--a document, a spreadsheet, a chart. The
format is the particular way the data is arranged inside the file. The format
of a file is known as its data type. When File Manager is in one of its
icon-view modes (see the Front Panel section for more information about File
Manager), you can identify the data type of a file by the icon used to
represent the file. Each data type has a different icon. This is similar to
Microsoft Office having different icons for Word, Excel, etc.
Most application programs
understand a limited number of data types. For example, a document editor
probably cannot read a spreadsheet file. The desktop helps you recognize
different types of files using a data type database. A data type identifies the
files of a particular format and associates them with the appropriate
applications. In most cases, when you double-click on a file, the desktop will
automatically launch the application that understands that file's data type.
The maximum allowable size
of a file name varies from system to system. Some operating systems do not
allow file names longer than 14 characters. If necessary, consult your system
administrator.
A folder is
a container for files, similar to a folder in a file cabinet. In fact, File
Manager uses a folder icon to represent a folder. A folder can contain other
folders-- sometimes called subfolders. With folders and subfolders, you can
create multiple layers of organization that form a hierarchy (in other
contexts, folders are often referred to as directories.)
If you drew a picture of
the folder hierarchy with each subfolder underneath the folder that contains
it--its parent folder--and drew a line from each folder to its parent, the
picture would look like an upside-down tree. Therefore, we often call the
folder hierarchy a folder tree. Within any single folder, each file name must
have a unique name. However, files in different folders can have the same name.
As you navigate from folder to folder, your current location (designated by the
UNIX prompt) is referred to as the current folder.
The
location of a file is often specified by listing the names of the folders and
subfolders that lead to the file -- this list is called a path (see the next
section Paths and Path Names). A file's path is visible in two places in
File Manager. First it is shown in the iconic path as a string of folders.
Second, it is shown in text form in the text path line above the view area.
The path to
an object (or file) is a way to specify where the object is located in the file
system. There are two ways to specify the path: absolute path and relative
path.
A path is
an absolute path if it begins at the root folder. The root folder is the
highest folder in the hierarchical folder tree. If a path begins with a slash
(/), it is an absolute path specified from the root folder. For the example
given below, the following is an absolute path…
to the folder prctc => /usr/201/prctc
to the folder lab3 => /usr/201/labs/lab3 OR /usr/314/lab3
to the file lab1a.java => /usr/201/labs/lab1/lab1a.java
to the file lab1a.cob => /usr/314/lab1/lab1a.cob
|
|
A path is
relative if it describes the location of a file or folder as it relates to the
current folder. If you are in a folder and you want to move down the tree from
that folder, you don't need to type the full path name. You can just type the
path starting with the name of the next folder in the path. If a path does not
begin with a slash, it is a relative path. For example, if the current folder
is /usr/201/, and you want to move to the folder /usr/201/labs/lab1, you would
use labs/lab1 as the relative path.
Two special folder names
are useful when specifying relative paths:
The . folder
(sometimes called “dot”) represents the current folder.
The .. folder
(sometimes called “dot-dot”') represents the parent folder -- the
folder one level up in the folder hierarchy. For example, if your current
folder is /usr/201/prctc, then the relative path to the lab1a.java file becomes ../labs/lab1/lab1a.java because the file is in the /usr/201/labs/lab1
folder.
Understanding
the thin-client/server model is critical to working effectively within the CIS
user environment. It will enable you not only to find data you need to complete
your assignments, but will also provide a key conceptual base for successful
software development. If your programs do not take the thin-client/server model
into account, you will run into problems in completing your assignments.
Obviously, if the commands you write cannot find the appropriate data to
process, or send the data through non-existent or poorly defined pathways, the
program will not provide the output you want.
When your account is set
up, you are given space on a disk on a specific file server where you will
store your program and data files. This is your home directory.
You can look at your home directory to tell which server has been assigned to
control your disk space. For example, if Alice has an account name of “alice” and her allocated disk space is on file server
“gold”', her home directory might be /n/gold/0/alice. Her home
directory will always be located at a specific server but it is possible to
access it from anywhere else on the network.
The names of the
directories in a pathname are separated by the slash symbol, /. The only
exception is the root directory, which is the topmost directory under which all
other directories are stored. Instead of “root”, the file system
assumes that any path beginning with a / should start in the root directory.
Finally, the tilde character ~ can be used as a shortcut for getting to your
home directory. Any user's home directory can be called as ~account-name; for
example, user “bob” can refer to
You should set up separate
subdirectories for your labs and projects, as they are a very convenient way of
organizing your disk storage. Subdirectories allow you to deal only with those
files that are needed for the current task. This minimizes the chance you will
become confused and change or even remove the wrong file. In addition,
protection mechanisms are possible at various places along a path, and this
provides for more efficient control of information.
In computer
terminology, a window is an area of a computer's screen that is associated with
a particular program. Users interact with programs through windows,
changing their locations on the display, and their sizes.
Window systems also provide
a convenient way for the user to work on several tasks at once. In a
conventional terminal session, a user typically will need to quit one
application before using another. Whilst this doesn't create a problem if the
user has finished one project and is on to another, it can if the job at hand
is a smaller, more interrupt-oriented task, such as checking email. Under
window systems, using multiple applications simultaneously is very easy; each
simply runs in its own window, independent of the rest.
In Unix,
a window can be minimized, maximized and closed similarly to a window using
Microsoft Windows. The windows can be minimized using the
“dot” button in the top right corner. The window can be
maximized using the box button in the top right corner (to the right of the dot
button). A window can be closed by clicking on the dash button in the top
left of the window and choosing from the drop down menu.
Press any
key on the keyboard and wait for the login prompt. If a menu appears, choose
the host “stdsun”. When you see the
username or login prompt, type in your username (usually your last name) and
hit return. At the "password:" prompt, type in the last four digits
of your social security number, followed by the first letter your first name
and the first letter of your last name in lower case. For
example, "5670bd". This is your default password. You will
next be prompted to change your password. Following the prompts, enter the
initial default password when it asks you for the "current password:". You will then be prompted to enter your new
password. Your new password should be five to eight alphanumeric characters. Do
not use only numbers. The computer will reject any password that is a simple
dictionary spelling of any known word. You must pick a combination of upper and
lower case letters, numbers and special characters to get the computer to
accept the new password. Do not use obvious passwords such as your first or last
name, your mother's name, or your favorite possession or sports team.
After you enter your new
password, you will be asked to enter it again to ensure that you did not make
any typing mistakes. You are now ready to begin working with UNIX.
To change your password at a later time, start up a terminal
window, and type the command passwd at the
command prompt and follow the directions.
Common Desktop
Environment (CDE)
To help you organize and
manage your work, the CDE contains windows, workspaces, controls, menus, and
the Front Panel.
Take some
time to become familiar with the windows and controls in the Common Desktop
Environment (CDE).
The default
Front Panel shows up at the bottom of your terminal window and includes the following
controls. Since it can be customized, your Front Panel may contain additional
or different controls.
Now that
you have a sense of what the user environment is like, it is time to begin to
learn the basic commands, which will allow you to work in your new workspace.
Please take some time now to work in your terminal window, following the
commands in the list below. The commands are in bold, with explanatory comments
in regular typeface. Enter the commands in the order given in the list. Use
these commands to familiarizing yourself with working in a terminal window.
Note that UNIX
is case-sensitive.
If you are having trouble, be sure you are typing in the commands exactly as
shown here.
ls Lists the contents of whatever directory is listed at
the Unix prompt. At this point, you should be in your home directory.
mkdir Lab1 Create a new directory (i.e make directory) called "Lab1".
ls Use ls to verify that a new
directory was created by listing the contents of the home directory.
cd lab1 This gives an error message --> "lab1:
no such file or directory". The reason for this is because Unix is case sensitive.
cd Lab1 Use cd
(i.e. change directory) to move to other directories - in this case, the "Lab1"
directory you just created.
ls Show that there are no files within the new "Lab1"
directory by using ls to list the contents of
"Lab1".
ls -l
/usr/class/cis314 Use this form of the ls
command to tell you the size, last date modified, and other information about
each file in the directory. Adding -l to the ls
command is called a switch, and many commands have them. Notice that by
providing the absolute path name you do not need to cd
to a directory to list its contents; also notice that your directory prompt
does not change either.
cp /usr/class/cis314/lab1a.cob
~/Lab1 Copy the file "lab1a.cob" to the "Lab1" directory
you just created. Notice that when using cp, you must specify where you want
the copy of the file to go. Remember, using "~" is shorthand for your
home directory. You could also have put your home directory instead of
the tilde (ex. /n/silver/2/reeves/Lab1)
cd If no directory is given, cd
returns you to your home directory.
ls Verify that you are back in your home directory.
cd Lab1 Move back to the "Lab1"
directory
ls Make sure that the copy was successful. That
is, you should have a file named “lab1a.cob” in your Lab1
directory.
mv lab1a.cob test.cob
Move or rename a
file. In this case, rename the file "lab1a.cob" to "test.cob".
ls Verify that the file was renamed. That is, you
should now have a file called “test.cob”
in your Lab1 directory.
cat test.cob
Lists the contents
of the file "test.cob".
more test.cob
lets you view a
larger document one page at a time. Press the space bar to move through the
document one page at a time, or press the return key to go down one line at a
time. Press return or the space bar until you come to the end of the document
and back to the default prompt. You can also press Ctrl-c (meaning press
the CTRL and C keys at the same time) to exit this command at any time.
Please notice that you
cannot edit text using more. To do this you must bring up the file in an
emacs window. The next section tells you how to do
this task. At this time, leave the terminal window the way it is and turn to
the next section.
The editor
you will be using is called XEmacs. It is an
advanced, self-documenting real-time display editor. We say that XEmacs is a real-time display editor because the text being
edited is visible on the screen and is updated automatically as you type your
commands. XEmacs is advanced because it provides
facilities beyond simple insertion and deletion, such as: automatic indentation
of programs; viewing two or more files at once; and dealing in terms of
characters, words, lines, sentences and regions. Self-documenting refers to the
fact that at any time you can call up documentation of XEmacs
from within XEmacs, simply by typing the character
C-h (that's pressing the Ctrl key and the letter H key at the same time) twice
then press the question mark key. This will list the XEmacs
commands you can use at present at the bottom of the window, and it also
describes what each XEmacs command does (follow the
directions to scroll and quit/exit this information).
To start Xemacs, go to the Personal Applications subpanel on
the Front Panel, and select Xemacs.
To move around in the emacs window, use the buttons to the left of the numeric
keypad on the right side of the keyboard. Here is a list of those buttons and
their functions:
Arrow keys: Move one character left or right,
or one line up or down.
Pgup, Pgdn: Move one page up or one page down.
Home, End: Move to the first page or the last
page of the current file.
In addition, you can use
the mouse to place the cursor exactly where you want to manipulate the text.
At this time, move your
mouse pointer to the top of the emacs window and
select the menu labeled "File." While holding the left button down,
drag the pointer down the screen. This will pull down a menu. The right side of
the menu shows keyboard equivalents for some of the menu choices. Find the
selection "Open...," and release the mouse button. The capital
"C" means that to perform the same task you could press and hold the
"control" key while pressing the next key in the command. For
example, you could open a file by pressing "C-x C-f" instead of
dragging down the file menu. In any case you should now get a prompt in the
command line at the bottom of the emacs window which
looks like this: "Find file ~/". Type in " Lab1/test.cob"
in the command line (you do not need to put the cursor in the command line,
just put it in the emacs window so the computer knows
which window you are working in and hit "return"; that is, the
“Enter” key. This command tells the computer to go to your
home directory and find the sub-directory "Lab1", and then to open
the file "test.cob". You should now see the
same file in your emacs window that you saw when you
used the "more" command earlier.
To see the column and row
numbers, go to the Options menu, choose Frame Appearance, and check the option
buttons for Line Numbers and Column Numbers. You will need to choose the
menu options twice; once for Line Numbers, then go back and select Column
Numbers. Now look at the bottom of your emacs
window. You should see something like this:
-----XEmac: test.cob-----L#--C#--Top
where L# is the line number the cursor is on, C# is the column number the
cursor is on, and Top is a reference to the % down the file the cursor
is in relation to the top of the file. Be sure to save these options
for use on future files by choosing the Options menu item and clicking on Save
Options. This is important because emacs will
sometimes start the column numbers at 0 which will cause problems in knowing
exactly where to put your program or data file information.
As described above, you can
edit the text in an emacs window. Hit return twice to
create space at the top of the program. Now, use the mouse to place the cursor
next to "AUTHOR" in the "IDENTIFICATION DIVISION". Now
enter your name like so: "Jane Doe-Smith". Next, go to
"File" and drag down to "Save Buffer" and release the
mouse. You have now altered the file "test.cob"
and saved the changes you have made.
When you need to close the Emacs window, choose the "File" menu option again
and drag down to "Exit Emacs". You
can keep many windows open at one time, but only one window can be active at a
time. Click on a window to make it the active window.
Return the pointer to the
terminal window and use more test.cob to make sure you have saved the changes to the file.
Do an ls and you will find a new file in the
"Lab1" directory. "test.cob~" is
a backup made automatically by emacs.
Remove the backup file
"test.cob~" using the rm
test.cob~ command. You will be prompted for the
file you want to remove. Enter the letter “y” (no quotes!)
FYI (do not do the following now) --> If you typed in rm test.*, this would to delete all
files that have the "test" filename no matter what the extension (the
portion to the right of the period in a filename). To remove (delete) all
the files you created (answer "y" to all the prompts.): rm *
Verify that the backup
"test" file has been removed: ls
Move back to the home
directory: cd
mkdir prelab Create a new directory with
the name “prelab”.
cd prelab Change to the new directory
mv ~/Lab1/test.cob . Don’t forget the period at the end of this command
which represents the current folder.
ls to verify the move command worked
ls Lab1/test.cob is an invalid command since you are not specifying the root
directory, and Lab1 does not exist under the current directory (~/prelab)
ls ~/Lab1 to verify that the move command did not leave a copy of “test.cob” behind
rmdir ~/Lab1 to remove the Lab1 directory.
cd .. to change the
directory up one level which takes you to your home directory (cd also works here)
You can recall previous
commands by continuing to press the up and down arrow keys.
Before you can compile and
run any source code program, you need to subscribe to the AcuCobol
COBOL compiler. To subscribe to COBOL, type subscribe at the UNIX
command prompt. Select the # associated with ACU-COBOL package from the
list (the number zero); press “q” to quit. You should receive
a message that says you have subscribed to the AcuCobol
compiler, and then you must log out and log back in to the system to
activate the subscription.
Email
allows you to send and receive electronic messages from users at
The on-line
documentation for the CSE department system and for the AcuCobol
compiler is available through Netscape. To access the documentation for the
compiler, type file:
/usr/class/cis314/docs/index.html
in the
location bar of your browser.
To lock the screen, select
the padlock from the Front Panel. When you are ready to resume your session
just type in your password and hit return.
Logging Out: When you are done with your
session you must log out. You do this by selecting "log me out" from
the background menu. This will close all of your windows and log you out of the
machine. Don't leave until you have verified that you are completely logged
out.
Problems with Hardware: If you have any problems with a
machine or a printer, make sure to ask the consultant to help you. Do not
attempt to fix it yourself. Do not turn off a machine for any reason.
Printing Policy: You are only allowed to have three
jobs in a printer queue at any one time. This is to be fair to other students
and give them a chance to print things out. If you have more than three jobs
you can send them to different printers or just send three at a time.
Do not print more than one
copy of something. The printers are not to be sued as copy machines. If you
need to print copies just go to one of the many copy machines located all over
campus.
Account Responsibility: Remember that anything that
happens on your account is your responsibility. Do not let other people use
your account. Make sure to either lock your screen or log out of your
machine before you leave the lab. It would be easy for someone to erase all of
your files or send nasty mail to someone from your unattended account.
Bitmaps: Do not display potentially
offensive bitmaps (gifs, rasters, pictures, etc...)
on your screen.
Academic Misconduct: Consultants can help you if
you have errors but they will not write your labs for you, so do not ask them.
For more information on
official policies see the "Computer Services" link of the CSE
homepage at http://www.cse.ohio-state.edu/cs/about.html