Welcome
Welcome to the CIS 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.
Before You Log In
The computer facility you will be using is a distributed network of Sun
Enterprise 450 servers with various thin clients. In general, we'll assume
that you're using an X terminal, though it's possible you're actually using
an HP workstation configured to behave as an X terminal. 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, version 11, release 6, 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 working in the
IICF efficiently.
The Thin-Client/Server Model
The computers in the CIS 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.
Client
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.
Login Server
These are the computers to which you login. So 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.
File Server
Login servers need not have a lot of local disk, because disk space is
provided by file servers. 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.
Hierarchical File System
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.
What's a File?
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, you can identify the data type of a file
by the icon used to represent the file. Each data type has a different
icon.
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.
What's a Folder?
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 is referred to as the current folder.
What's a Path?
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
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.
Paths and Path Names
The path to an object 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.
Absolute Paths
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 example, the following is an absolute path to the file letter:
/usr/dt/config/letter
Relative Paths
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 folder tree, 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/dt,
and you want to move to the folder ''/usr/dt/config/letters,''
you would use the following relative path:
config/letters
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/dt/config/panels,
then the relative path to the sys.dtwmrc
file becomes:
../sys.dtwmrc
because the file is in the /usr/dt/config
folder, one level above the current folder.
Disk Storage and the UNIX File System
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 name 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 Alice's home directory
as ~alice instead
of /n/gold/0/alice.
In addition, tilde can be used by itself to refer to your own home directory;
in other words, user Alice could refer to his own directory as alice, but
could also refer to it simply as ~.
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 which 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.
Computer Windows
In computer terminology, a window is an area of a computer's screen that
is associated with a particular program. An example can be seen in figure
2. 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.
First Step: Logging In
Press any key on the keyboard and wait for the login prompt. When you see
the "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 your first and last initial 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. Follow the directions.)
Common Desktop Environment
To help you organize and manage your work, the Common Desktop Environment
contains windows, workspaces, controls, menus, and the Front Panel.
-
Windows contain software applications and are framed with controls so you
can move them, size them, or place them in additional workspaces.
-
Workspaces are the screen areas where you place the windows needed for
your work, arrange them, and put them away when you're done.
-
Controls enable you to manipulate objects, select choices, or type information.
-
Menus provide access to commands you use to manage windows and operate
applications.
-
The Front Panel is a collection of frequently used controls, available
in every workspace.
Take some time to become familiar with the windows and controls in the
Common Desktop Environment (CDE).
Front Panel
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.
-
Clock - The clock window displays the current time and date. Besides informing
you of the time, this window can be used to determine if there is a problem
with your machine. If the time does not change for several minutes, there
may be a problem somewhere in the system. If you think there is a problem,
contact a CIS operator.
-
Calendar - To the right of the clock is a calendar icon, which displays
the current date. If you click on the calendar, the CDE calendar program
will be initiated.
-
Folders Subpanel - To the right of the calendar is a subpanel, that is
an icon with an arrow over it that will expand to a list if clicked. File
Manager may be started from this subpanel. As is true with icons on the
front panel, when an icon in the subpanel is clicked, the corresponding
program is started.
-
File Manager displays the files, folders, and programs on your system as
icons. Working with File Manager icons saves you from having to learn complex
commands. To open a File Manager view of your home folder, click the Home
Folder control in the Folders Subpanel.
-
Personal Applications Subpanel - To the right of the folders subpanel is
a terminal icon. That subpanel will expand to list a number of applications,
including XEmacs and a simple text editor. If the terminal icon itself
is clicked, a terminal window will be started.
-
Your terminal window is used for executing UNIX commands and running UNIX
programs. When you want to enter a command or run a program, move the mouse
cursor into the window and type the command at the prompt. The default
prompt is a percent sign. When there is more text in your xterm window
than will fit, the text at the top of the window is scrolled off of the
window. The vertical bar on the right side of the window is a scroll bar.
You use the scroll bar to see information that has scrolled off the top
of the screen. If you want to stop a program that is running, you can type
control and c together.
-
Mozilla Subpanel - ``Mozilla'' is the codename of Netscape's web browser.
The corresponding icon is that of ``Navigator'', Mozilla's more formal
name. Clicking the Navigator icon will start a web browser. Clicking the
``mail'' or ``news'' icons in the Mozilla subpanel will start Mozilla's
mail and news clients, respectively.
-
Lock - The padlock icon can be found on the top-left part of the center
section. Clicking it will lock your screen. This will cause the screen
to blank. It will be necessary to enter your password again to resume your
session. Do not lock clients in order to reserve them for future use; this
should only be done when you're still working, but leaving the keyboard
momentarily, i.e., to fetch a print job.
-
Workspace switch - By default, there are four desktops in CDE. Oddly enough,
these are labeled ``One'', ``Two'', ``Three'', and ``Four''. Sometimes
it is convenient to spread your work across multiple desktops. For example,
you might be writing your program in one desktop and then in another, have
the program running. Clicking on a desktop button will take you to the
corresponding desktop. Double-clicking these will allow you to change their
names to things that are more interesting and useful.
-
Busy Light - When a CDE action is running, i.e., just after you clicked
the Netscape Navigator icon, you'll see the busy light flashing. The light
will stop flashing once CDE has done its job and started the application,
or finished whatever task you've given it to do.
-
Exit - Clicking the exit button will initiate logout from CDE.
-
Printer Subpanel - On the right half of the front panel, there is a printer
icon. The subpanel there is used for programs like the printer manager,
which will show some of the printers that are available to you. The correct
printer will be determined based on your client's location, so you needn't
worry about this.
-
Style Manager - To the right of the printer is an icon of a mouse, some
letters, and a bit of a window. This is the Style Manager, which is used
for defining the look and feel of your environment. Starting Style Manager
will present you with a window which will allow you to configure your environment
to your tastes. The best way to determine which behavior works best for
you is to try different settings. For example, do you like clicking in
a window to make it active, or would you rather have any window with your
pointer in it be active? The ``window'' option in Style Manager will let
you choose which behavior your environment follows.
-
Application Subpanel - Next is the Applications subpanel, under which you'll
find ``Desktop Apps'', which has such things as ``Application Builder''
and ``Create Action'', tools for creating your own CDE applications and
actions. Also, you'll find a system manual page viewer, and some other
things.
-
Help Manager - The icon picturing a question mark in front of a few books
is the Help subpanel. There, you'll find detailed information about the
help viewer itself, desktop information, the front panel, Sun's AnswerBook,
and some information that's of specific interest to the local user community.
-
Trash Can - A wastebasket is pictured on the rightmost side of the front
panel. Files can be dragged into the trash can from the File Manager to
be deleted. You'll almost certainly find it easier to use rm, as explained
later.
Working with UNIX
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
your are in - in this case your home directory.
mkdir Lab1 Create a new 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 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 pathname you do not need to cd to a directory to list its
contents, your computer will do it for you.
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. Using "~" is shorthand for your home directory.
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.
mv lab1a.cob test.cob Move or rename
a file. In this case, rename the file "lab1a.cob" to "test.cob".
ls Verify the move.
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 on e 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.
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.
Working with XEmacs
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 (remember, that's ``Control-H'') twice.
This will list the XEmacs commands you can use at present, and it also
describes what each Xemacs command does.
The Sun Solaris environment runs version 21.1 of XEmacs.
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 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". 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.
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~" and the original "test.cob" using
the rm test.cob test.cob~ command. You will be prompted for each
file you want to remove. Enter "y" each time. FYI (do not
do the following) --> You could also have used rm test.* 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 "test" files have been removed: ls
Move back to the home directory: cd
To remove a directory: rmdir dirname Replace
the actual directory name in place of "dirname". For instance, "rmdir
Lab1", however, we do not want to use this command at this time.
You can recall previous commands by continuing to press the up and down
arrow keys. Use the up arrow key to recall the copy command (cp /usr/class/cis314/lab1a.cob
~/Lab1), edit the command by replacing "~/Lab1" with either a single
period or a tilde, and then press Enter. You again have the lab1a.cob
file in your Lab1 directory.
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. Then you must log out, and log back
in to the system.
Email
Email allows you to send and receive electronic messages from users at
Ohio State and elsewhere. Along with your CIS account, you have a CIS email
address. It looks like username@cis.ohio-state.edu. When you use
the CIS submit tool to submit your labs, email will be sent to your CIS
account if there was any problem submitting your labs - maybe you entered
the wrong class name, or typed the wrong file name. Be sure to check your
email often this quarter. Only the information
on your CIS account will be considered should a problem occur. That
is, if you are deducted points on a lab for whatever reason and you have
your CIS account fowarded to another account and deleted from your CIS
account, then any information not on your CIS account will not be considered
valid evidence to support any difficulty that may have occurred.
So, remember to keep all important files, data and emails on your CIS account
this quarter.
You can use Xemacs to check your email. Go to the Apps menu in Xemacs,
and select read mail.
Netscape
The on-line documentation for the CIS 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.
For system documentation, please visit the department web page at www.cis.ohio-state.edu/Computing-Environment
Lab Use Guidelines
Locking Screen: If you need to leave the lab, for any reason, and
you know that you will be back in less than fifteen minutes you should
lock your screen. If you are going to be gone more than fifteen minutes
then you should log out to allow another user to use the machine.
To lock the screen just 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: All work is supposed to be done by you and
only you. Consultants can help you if you have errors but they will not
write your labs for you, do not ask them. Do not copy your peers labs either,
consultants will be monitoring this.
For more information on official policies see the "CIS Policies" section
of the CIS homepage as well as the policies appendix in the UNIX Guide
for new Users (also available form the CIS homepage as "CIS Help").