Seminars are given by system staff of the School of Computer Science (SOCS),
of McGill Univeristy, as a service offered at the start of each fall and winter
term. Apart from systems and network administration, SOCS system staff also
provide a daily user support service called the SOCS Help Desk.

The SOCS Help Desk is the user support centre for answers to computing
questions of students, faculty, staff, and anyone else having a valid account
at the School of Computer Science at McGill University.

The SOCS Help Desk is physically located at the McConnell Engineering Building,
in room 209N. For help, call 398-7087 or send an email to help@cs.mcgill.ca.
For more information about the SOCS Help Desk, please consult:
http://socsinfo.cs.mcgill.ca/wiki/Help_Desk

When sending mail to the Help Desk make sure to complete the subject field.
Write one to four key words that are relavent to your email. Write short
messages that get to the point. In most cases you should include the name(s)
of the host(s), or computer(s), involved in your particular problem.

For information about issues specific to SOCS, such as user accounts, the
network, and services, please consult: http://socsinfo.cs.mcgill.ca

Every user is responsible for their account. Users are not permitted to
give-to nor share their account password with anyone. The account password
must compose of 8 random characters, including atleast one letter, numeral, and
symbol, and should not be a word, or set of words of any language. Users must
protect their account password. Users must not attempt to circumvent security.
Users must not execute binaries, and/or compile and run programs given by
someone else. Users must never put a ``+'' in their .rhosts file.

At SOCS, we all adhere to a "congenial atmosphere", please do so as well.

UNIX has a convoluted history, but roughly speaking, it was originally invented
by Ken Thompson in 1969. Dennis Ritchie, the inventor of the C programming
language, is considered to be the co-author of the system. UNIX was
reimplemented almost entirely in C during 1972-1974, making it the first
source-portable OS. You can read more about UNIX in Wikipedia, a free
encyclopdia, at: http://www.wikipedia.org/wiki/Unix

Technically, UNIX is proprietary software originally owned by AT&T, and now
partially by Novell, SCO Group, and The Open Group - it's very unclear.
Despite UNIX being one of the most influential operating systems in history,
nowadays hardly anyone uses UNIX; instead people use variations of the
original UNIX that have been created since the early 1980s, including many
free variations (that is, free of restrictive copyrights), such as Debian
GNU/Linux, RedHat Linux, FreeBSD, and OpenBSD. You can read more about the
definition and philosophy of free software at:
http://www.gnu.org/philosophy/free-sw.html

It is incorrect to refer to any of these variations as "UNIX"; it is better to
say "UNIX-like". In practice however, because 99% of the time people only
speak of UNIX-like systems anyway, the intended generalization is understood.

In this document, to acknowledge the distinction between the original UNIX and
the loose generalization, the spelling "Unix", with only the first letter
capitalized, will be used to refer to any common UNIX-like system.

Unix is a multi-user and multi-tasking operating system. "Multi-" is a
combining form indicating "more than one". Therefore, in this context,
multi-user means that a system is capable of being used by more than one user
at the same time. Multi-tasking means that any user may run more than one task
(aka program, or job) at the same time.

"User" is often a combining form indicating "a person or thing that uses"; in
this context it is short for "computer-user". A "task" is any piece of work.
[*]

If you are unfamiliar with a multi-user operating system you may wonder how
so many users can use a computer at the same time.

To understand, first note the following terms. A device is a computer
hardware designed for a specific task. A channel is a path along which data
can be transmitted.

Next consider the keyboard (an input device) and the monitor (an output device)
as a pair forming an input/output channel to a computer. A device having
input/output links with a computer is called a terminal. Now imagine many
such terminals attached to one Unix machine.

Sharing one computer is possible because Unix is a time-sharing operating
system, that is, an operating system with which its users (at different
terminals of a single computer running Unix) can, because of its design and
high speed, seemingly (or apparently) communicate with it at the same time.

For the sake of order and security, each user of a Unix system has a separate
account. An account is something like an office, because it is a place to do
work and store things related to that work.

Each account is uniquely identified by a number called a
user identification number (or uid for short), as well as an account name,
generally referred to as a username, and an associated password (a secret
word that ensures admission by proving one's identity).

Account information, along with absolutely all other information in a Unix
system, is stored in entities called files, similar in concept to ordinary
office files. Files can be grouped into directories, just as office files
can be grouped into folders. A directory can contain files as well as other
directories, just as an office folder can contain files and other folders.
However, unlike office folders, which are limited by physical constraints,
directories can be nested to no impractical limit.

To be nested means to be positioned within something. For directories to be
nested means for them to be positioned within other directories.

One structural constraint of directories is that all directories ultimately
stem from one directory called root (abbreviated as a single forward
slash: `` / ''). Another constraint is that any single directory must contain
files with unique names, but files in different directories can have the same
name without any conflict. [1] [*] [1 TUPEnvironment, p. 21]

A filesystem is a logical subdivision of hard disk space. Characteristic of
a Unix filesystem is its hierarchical structure. Hierarchy refers to any
system of things or persons arranged in a graded order, such as the structure
of government, or the socioeconomic structure of our society [*]. In this case
we are talking about a system, or structure, of directories and files in a
nested order, beginning with the root directory. [*][*]

The filesystem is recursively defined in the form of an upside down tree,
starting with the 'root' directory at the top. Recall that the root directory
is simply named ``/''. It is not contained in any other directory, but from
it all other directories descend, directly or indirectly. A file path is a
description of a file's residence relative to some directory. A file path
relative to the root is called an absolute path, and would start with ``/''.
Note that all subsequent slashes in a path name are delimiters that separate
directory names.

While introducing the notion of a user account, it was mentioned that each
account has an associated uid, username, and password for the sake of order
and security. Well, futher to this reasoning, each account is also
allocated a unique place on the filesystem to store the account owner's
personal files and do work. That place is actually a unique directory within
the filesystem, and is called a home directory (commonly abbreviated to
home dir, hdir, or home). [*]

A path can be specified relative to a user's home directory, by a leading
``~'', or to parent directory (the directory immediately above any give
directory), by a leading ``..''. A path can also be specified from the
present working directory (pwd) by a leading ``.''.

No user is permitted to access another user's home directory, nor anything
beneath it. Infact, it can be made possible for other users not to be able to
even see what is within a user's home directory or their files. Equally so, it
is also possible to grant permission for certain users, or all users, to read,
write, and/or access a file or directory. The concept of permissions will be
discussed within the intermediate-level material.

To use a Unix system, a user must have an account on that system, and must
gain access to that account by proving identity by a process of authentication
called log-in. A user "logs-in" by inputing a valid username and associated
password. [*]

Logging-in is possible in two ways: via a graphical user interface (aka
graphic console), or via a text user interface (aka text console). An
interface is a common point, boundary, or link between two things - in this
case it is a link between a human and a computer.

Regardless of how you login (short for log-in), you must enter your username
and password (each followed by pressing the ENTER key). Two things to note
are that the username must be typed in lower case, and that when you type
your password, the characters will not appear on the screen. The password is
concealed in case someone is peeking over your shoulder.

A login session (or session for short) is established upon successful
entry of the username and password. "Session" is a "lasting connection",
which in this case is between a user and a system.

The appearance of the login session via the text console will be significantly
different from the login session via the graphic console. Both have advantages
and disadvantages depending on the circumstance, but as far as the following
instructional example is concerned, the graphic console requires an additional
step to arrive at something that the text console immediately provides.

So if you've logged-in via a graphic console, the additional step is that you
will have to open what's called a terminal window (aka terminal, or
term). This can be accomplished by using the mouse to click on a terminal
window icon, or by selecting a "terminal window" option from a mouse menu,
though the specifics will be very system-dependant.

Regardless of login method, the login event will be registered (or logged),
in a log file. Following the opening of a terminal window, the things that
follow will be the same as what appears on the text console.

After you have logged-in, and in the case of a graphic console, after
you have also opened a terminal window, the system might display a message of
important information, known as message of the day (or motd for short).

Following the possible motd, you will be presented with a command-line
consisting of a command-prompt and a cursor.

A command-line is a row on which commands (instructions for the system) can
be entered. A command-prompt (or prompt for short) is a symbol that
indicates the beginning of a command-line. When a shell is ready to recieve
commands, it displays a command prompt. A cursor is a movable point that
identifies a specific position on a visual display unit. In the case of a
command-line, the cursor is usually either a blinking or solid underscore or
vertical bar, that marks the current typing position.

A shell can read command lines from a terminal (interactively) or it can read
them from a file (this is known as a shell script). Shell scripting will be
discussed within the advanced-level material.

The symbol that represents the prompt could be something as simple as a single
character, like a dollar sign (``$''),
or a percent sign (``%''). It could also be the name of the machine you're
using in square brackets (``[tron]''), or something even more elaborate.

The command line, prompt, and cursor are visual aids of what's called a
command interpreter (or shell for short). The shell understands a certain
language known as a shell command language, which is used to access a
computer system. Commands entered on the command-line are passed to the shell
for execution by the system, therefore the shell is an interface to the system.

At this point, nothing will happen unless you enter a command. Charles Snow, a
former instructor at McGill University, once said: "The shell waits with
amazing patience and anxiety for you to type something." [*][2000.09.19]

Every command has the same structure: the command name, which tells the
shell what command you want the system to execute; and the arguments, which
detail what you want the command to do, how you want it to do it, and to what
you want it done. Some commands consist of only the command name, and do not
take arguments; on the other hand, some commands require arguments.

command_name [argument(s)/parameter(s)...]

The arguments are also known as parameters, and are separated from each other
by spaces. The parameters are separated by spaces to distinguish one parameter
from another. The parameters of the command are further divided into options
and names. Options are usually prefixed by a hyphen (``-''), or double
hyphen (``--''). Names usually name the files that the command should use in
its operation.

Let's assume that the prompt is a percent sign. A simple command to try for
the first time is one that invokes a program that reports the date and time.
The program is called ``date'', and the command requires nothing more that
that. Type "date" and press ENTER. The system will respond by displaying
(aka printing) the date and time, followed by another prompt.

% date
Tue Mar 4 03:59:55 EST 2003
%

The ENTER key must be pressed to invoke all commands, so from this point on
in this document that will be implicit.

A user's initial working directory is that user's home directory. Since we
haven't done anything to change it, it will still be that, but we can confirm
just out of curiosity. In fact, you can determine your present working
directory at any time by typing the command ``pwd'', as follows.

% pwd
/home/users/abatko
%

The proper way to logout (exit the terminal, or session) is to simultaneously
press the CTRL key and D, although if that doesn't work, you can also logout
using the command ``exit''.

An editor is a program that enables the creation and modification of text
files. For a detailed coverage of the most common text editors at SOCS,
read the web page: http://www.cs.mcgill.ca/~navindra/editors/

This is a list of some editors described on the aforementioned web page:

% gedit - Simple text editor for Gnome with syntax highlighting and
spell check.
% kate - Simple text editor for KDE with syntax highlighting and
spell check.
% xemacs - XEmacs is perhaps the easiest power editor for newcomers to use.
XEmacs splintered off of the GNU Emacs effort some years ago;
though today GNU Emacs and XEmacs are mostly still the same,
each has a variety of features not supported by the other.
% emacs - GNU Emacs is a remarkable editor and its various
characteristics such as extensibility, customizability, and
innumerous bundled packages are particularly appealing to
the programmer.
% nano F - Nano is a simple text-only editor, suitable for a novice or
anyone wishing to invest only a minimum amount of time in
learning an editor.
% pico F - Pico is a simple text-only editor, suitable for a novice or
anyone wishing to invest only a minimum amount of time in
learning an editor.
% vi - Vi is one of the most powerful and versatile editors with an
abundance of features such as macros, and filter and
scripting support. On top of this, vi is available on just
about every UNIX-like system, and is very lightweight. It
should also be noted that vi has two modes: a command mode,
and an insert mode.
% vim - VIM is Vi IMproved and has many advantages over standard vi.

If you try vi or vim and you don't know how to quit,
press the escape key (``ESC''),
followed by ``:q!'' (colon, q, exclamation).

% cd - Change the pwd to the user's home directory.
% cd D - Change the pwd to the directory D.
% cd - - Change the pwd to the previous working directory. (Note that
"previous" does not mean "parent"; it means the directory
that was pwd immediately prior to what it currently is.
Using a hyphen (``-'') in this manner will only work for cd,
it will not work for other commands.)

% less F - View the contents of file F, one screenful at a time. To
scroll forward press the SPACEBAR, or ``f''. To scroll
backward press ``b''. To return to the top of the file,
press ``g''. To quit viewing the file, press ``q''.

The on-line reference to commands is called the Reference Manual Pages,
or manpages for short. Manpages describe most commands available on the
system, providing both quick reference and detailed coverage. An interface to
this on-line reference maual, is a utility called ``man''. Manpages are
separated into nine "sections". Section 1 is the most important section to
users, since it describes all user commands (executable programs and shell
commands):

The manpages themselves may be subdivided into "parts" most commonly labelled
as follows:

NAME - The name of the command being described.
SYNOPSIS - A pattern describing all possible invocations of the command.
DESCRIPTION - Detailed description of the command.
OPTIONS - Description of arguments illustrated in SYNOPSIS.
FILES - Description of files associated with the command.
SEE ALSO - References to related commands.
HISTORY - Brief history of the command's creation.
BUGS - Outline of known problems with the command.
AUTHOR - Who wrote the command.

There are two types of computer resources available for users to get work done,
namely workstations and compute servers. Workstations are physically
accessible machines for users to sit in front of to do their work. Compute
servers are not physically accessible, and are ones designated for
remote login (discussed below) for the purpose of running applications for
any number of reasons such as more compute power, uninterrupted execution
time, special appications, etc.

All labs are located in Trottier building, on the 3rd floor; these are
currently accessible by all students holding valid SOCS computer accounts,
and taking CS and/or ECSE courses. As far as Unix-like systems are
concerned, SOCS labs are populated only by free unices, namely FreeBSD and
RedHat Linux.

SOCS provides several compute servers for those wishing a platform for
long-running, or to try out a different version of UNIX than they
are used to. The compute servers are only available by remotely logging in.

Some of the compute servers run by the proprietary Unix flavor called
Solaris (from Sun Microsystems) - mainly because they are Sun Sparc
machines.

For more information about SOCS compute servers, please consult:
http://socsinfo.cs.mcgill.ca/wiki/Servers

Logging into a remote machine is possible by using a remote login program.
Further to remotely access a SOCS machine it is necessary to use a secure
remote login program, often referred to as a secure shell client. ``ssh''
is the program available on every SOCS machine for this purpose. To log in
from home or elsewhere, you must also use a secure shell client. For more
information about ssh please consult: http://socsinfo.cs.mcgill.ca/wiki/SSH

Below is an example of how to log into the compute server mimi for the first
time; it is necessary to answer ``yes'' to continuing the connection.

Recall that every account is given a home directory on the filesystem to store
the account owner's personal files. Filesystem disk quota, (or quota for
short) is a prescribed limit to the amount of disk space that an account can
use on a given filesystem. Accounts are limited to the amount of space that
they can use so that disk space usage can be controlled.

The hard quota is the maximum amount of disk space that the system permits a
given account to use. Reaching the hard quota can have nasty side effects: the
system will not permit any operation that requires using additional disk space;
attempting to edit files my corrupt them; and logging-in may fail (this problem
is discussed below). The hard quota takes effect as soon as it is exceeded.

The soft quota is less than the hard quota and it is the point at which the
user will be warned about approaching the hard quota. The warnings depend on
the operation performed when attempting to write data, and also on the system
that the operation is being performed on. It is important that users resolve
the quota problem as soon as possible because of the severe consequences that
may result when the quota limit is approached. Exceeding the soft quota for
more than seven days automatically turns the soft quota limit into the hard
quota limit.

It is common that when attempting to login via a graphic console, the login
process may momentarily display the graphical desktop environment, and then
immediately be thrown back to the login prompt. This behaviour indicates that
the account has
approached too close to the hard quota for the windowing program to be able to
write data to special files in the account's home directory - which is
something that some windowing programs do as part of their operation. To
resolve this problem it is necessary to login via the text console.

Simultaneously press Ctrl-Alt-F1 to switch from a graphic console to a text
console. To switch to a graphic console from a text console simultaneously
press Alt-F3 or Alt-F7. Note that the "Ctrl" key is not necessary when going
from text to graphic console. If you can't find what
you're looking for on either direction, there is no harm in cycling through all
the function keys (F1-F12).

Once you're log in, regardless of whether it is via the graphic console or the
text console, you will need to delete some files to return to below the soft
quota limit. Commands to delete some directories and files are listed below:

rm -f ~/*core

If deleting these files doesn't help, you will have to visit a
System Administrator for further assistance.

The World Wide Web (WWW) is a universe of network-accessible information. Tim
Berners-Lee invented the World Wide Web in late 1990 while working at CERN, the
European Particle Physics Laboratory in Geneva, Switzerland.

It has a set of protocols and conventions, and uses hypertext and multimedia
techniques to enable anyone to browse it, or contibute to it. Evolution of
WWW is coordinated by W3C - World Wide Web Consortium, http://www.w3c.org/

% lynx - A text based, frame and java disabled WWW browser.

If you are logged-in via a graphic console, look around the graphical desktop
environment for an icon to laungh a graphical WWW browser. If you can't
find an icon, you can enter one of these commands:

Can also use POP paradigm, for minimum connect time and server resources.

The mail system at SOCS is built around an independent mail server
mail.cs.mcgill.ca, supporting both POP and IMAP.

``webmail'' is the preferred mail client for most users because it is
web-based, intuitive, and full of important features such as spam control and
mail filtering.

Note that the incomming mail server is "mail.cs.mcgill.ca", and within the CS
domain the outgoing mail (SMTP) server is also "mail.cs.mcgill.ca". If you are
outside the CS domain, you can try "mailhost.mcgill.ca".

Once you've used an editor to create your program, you are ready to complie
it. Depending on what language you used to write your program, you will need
an appropriate compiler.

Please note that the word "foo" is used very generally as a sample name for
absolutely anything, especially programs and files. To avoid confusion, "foo"
is never made the name of a real file.

% cc foo.c - C complier. Compiling the program foo.c may result with the
creation of an executable program called a.out or an error
message from the compiler.
% gcc foo.c - GNU project C compiler. Compile the C program foo.c.
% g++ foo.cpp - GNU project C++ compiler. Compile the C++ program foo.cpp.
% javac foo.java - Java compiler. Compile the java program foo.java
into a file called foo.class.

At SOCS, we have several different versions of the java compiler installed on
the workstations. Please see http://socsinfo.cs.mcgill.ca/wiki/Java for information on how to switch between versions of java.

To print at SOCS, a user must have a positive printing fund balance.
The issuer can check her/his balance using the ``balance'' command on
any lab machine.

[lab6-1] % balance

It is not possible to print plain text files directly. Plain text files (aka
ASCII files) can be printed using the command ``a2ps'' with the -d option to
print to the default printer. To print to a non-default printer, use the -P
option.

% a2ps -d file.txt
% a2ps -P name file.txt

There is a printer in each lab room. The printers are named lp#, where # is
a lab room number. For instance, lab 3070 is referred to as lab 7, so the
printer in lab 7 is named lp7.