UNIX Lecture Two
As it appeared when it was first sent via email.
Greetings Everyone,
Before I begin with today's lecture I would like to address
a few things brought up by a few of your comrades.
I received a few emails asking me to make the lectures shorter,
and I also received a few emails asking me to make the lectures
longer. For now, I do not think that the lectures will be either
shorter or longer. Please understand that while some of you are
advanced in your knowledge, others are not so advanced, and what
may seem short to you may be long for others. Also, there are
time constraints to consider, for me and for you. While some
people will have time to read, for example, 20 pages, others
will only have time for 3 or 4 pages. So for now I will leave
the length as it is, mostly determined by the topic, sub topic,
or idea that is being presented. If time permits I will add some
supplemental material someplace on the Russian News Network website.
Also, if anyone has any questions or comments that you think might
be of interest to at least some other people, send me an email.
Depending on the number and nature of the questions, I will post
the questions and the answers someplace on the website mentioned
above. If the questions are few in number, I will answer them here,
during lectures (or in a supplemental mini lecture that I'll email
to everyone).
(Lecture continued after this important
sponsor break…)
Visit THE TECHNOLOGY CORNER for all your computing
needs. We have books and manuals on everything
under the sun! Our motto: “All the Data You Need”.
http://www.vstore.com/vstorecomputers/a1techcorner
(This week’s lecture continued…)
Today's lecture....
I would like to start by talking about the UNIX System Layers.
The UNIX Operating System consists of the following layers:
CORE
The core refers to the hardware, nothing more.
KERNEL
The kernel is a collection of programs that handle the hardware
resources (I talked a bit about the kernel last time).
UTILITIES
These are a collection of specialized programs that are
independent of the hardware.
SHELL
This is the outermost layer. The shell establishes the interface
between the user and the rest of the system. The shell is what
interprets your commands for UNIX systems, meaning that when
you type a command, the shell tells the system what you want it
to do. For now keep in mind that the shell is the command
interpreter for UNIX systems.
There are three shells that are commonly available on UNIX
systems. They are as follows:
The Bourne Shell
This was the first major shell created for UNIX . It is named after
its creator (S.R. Bourne) and is the standard version available
on version 7 UNIX systems. However, it is also available on almost
all UNIX systems. This shell is denoted by:
"sh"
and has the American dollar sign as the prompt symbol: "$"
The second shell is the C Shell
This one was created by William N. Joy. It is commonly used in
the BSD based systems. This shell is denoted by:
"ksh"
and has the percent sign as the prompt symbol: "%"
The next shell is the Korn Shell
The Korn shell is also named after its creator, David Korn (AT&T Labs).
This shell is the new shell, which is a superset of the Bourne
shell. It is denoted by:
"ksh"
and has the American dollar sign as the prompt symbol: "$".
SOme major shell features....
1) Analyses of the Command Line and Run Command
What this means is that it starts the command that you indicate
you want performed, and passes the remainder of the command line
as "arguments" to the command (Those of you who have some knowledge
of Calculus or advanced Algebra will probably feel comfortable with
the "argument" concept). The shell runs each command as a separate
job. Such a job can be run in the foreground. The shell runs each
command as a separate job. Such a job can be run in the foreground
(meaning that you are specifically waiting for the job to be
completed) or it can be run in the background (out of site), so that
the shell returns immediately and the user can continue typing in
more commands.
2) Input and Output Redirection
The shell redirects the standard input (meaning data that is to
be processed), standard output (the result, typically displayed on
the monitor for viewing, etc) and standard error (this is any
unwanted output, usually sent to a file that you, as the user, specify)
defined by the user.
stdin (standard input) is represented by a 0 (zero).
stdout (standard output) is represented by a 1 (one).
stderr (standard error) is represented by a 2 (two).
3) Pipes
This is a tool that is used for the implementation of inter process
communication. The shell can arrange for the standard output of one
command to be used as the standard input of the next command line.
In this manner, multiple commands can be connected, resulting in a
connection that is called a "pipeline".
4) Meta Character Expansion
The shell is very gracious, and allows for meta character usage. Some
of the more common meta characters are the question mark ("?" - this
matches any single character in a file name, used when performing
searches), the asterisk ("*" - this matches any string of characters,
including the empty strings, in a file name) and the two "square
brackets", i.e., "[" and "]". The shell performs the meta character
substitution first before taking any further action.
5) Set Path
What this refers to is the fact that the shell provides a way for
the user to set the search path to be searched by "search" commands.
(I know this may sound like a strange sentence but it really means
what it says).
6) Programming Language
The shell can be used as a programming language. To do this, all
that is needed is to place a collection of shell commands in a file
(along with control structures - more on these later), change
permissions on the file (more on permissions later) and the filename
can be used just like any shell command. This new command (which the
filename now is) runs the shell commands in the file. Thus, you are
effectively running a customized program that you created.
Some Special Features of the C Shell...
1) History Facility
The history mechanism maintains a list of previously used commands.
Indicating the number of the command on the list can re issue any
command from the "history" list. It is also possible to change parts
of a command from the history list before executing it.
2) Job Control
Jobs that are running can be put on hold. These jobs are not terminated
completely, only stopped. This means you will have the shell prompt
to do other things, and you can reactivate the stopped jobs whenever
you wish. When a stopped job resumes, it continues from the point at
which it was stopped.
3) Alias Mechanism
"Alias" is a tool that allows users to assign their own names for
frequently used and/or long commands. The syntax of C shell commands
resembles the C programming language. For comparison, the Bourne
shell commands resemble something called Algol-68.
Special Features of the Korn Shell....
1) Superset of the Bourne Shell
What this means is that the Korn shell has all the features available
in the Bourne shell, with a few more added on.
2) Includes the Best Features of the C Shell
The Korn shell includes all the useful features of the C shell, with
a slightly different syntax. This means that the Korn shell has a
"history" facility", "job control" and the "alias" mechanism. In
addition to these things the Korn shell also has:
A) Command Line Editing
The Korn shell allows the user to display the previous commands
on the command line, make changes, and then execute the resulting
new command.
B) Easy Integer Arithmetic
Handling integer arithmetic in the Korn shell is more convenient
than in the Bourne shell. In the Bourne shell it is necessary to
use a command with complicated syntax, while in the Korn shell it is
as simple as issuing commands in the usual way, with arithmetic
operators and the assignment symbol.
C) Function
The Korn shell supports memory resident functions as well as
functions in shell programming.
These are the basic ideas behind the "shell" concept. I thought
it necessary to introduce these ideas to you early on.
Now, a little about login in to a UNIX System....
To gain access tot a UNIX system you need a user account. This
means that you must have a "user id" and a "password" to login
to a UNIX system. Now I can hear some of you saying, "but there
are many operating systems that require a user name and password!"
Yes, that's true, I am merely pointing out that UNIX has this
feature.
When you first turn on you computer and the operating system has
finished loading, you will be prompted with a "login:" prompt (this
prompt may vary from version to version). At this point type in your
user id.
Aside: It is generally not advisable to log in as "root", since
you can potentially damage the operating system if you are not
100% sure that you know what you are doing.
For our purposes, however, we will be login in as "root" anyway.
The system will next ask you for a password. Type in whatever
password you assigned for the "root" account during setup. If you
do not remember the password, there is no way for you to gain access
to the system and you will have to reinstall the operating system.
If you are using one more popular Linux distributions (the free ones),
then all you have to do is insert the cd, boot from the cd-rom and
choose "upgrade" when "setup" asks you what type of installation you
want. Choosing the upgrade option is usually the fastest option
(about 15 minutes) and it is also the easiest. Once logged in you
would be ready to execute commands, etc.
We will work some more on this next time.
A word of caution...
Be sure that you are permitted to install UNIX/Linux on your computer
before you install anything. What I means is: if you are at work or
at school, you probably are NOT permitted to install things on work
and school computers. If you already have a UNIX or Linux system
installed (as are found at many engineering schools), it should be
alright for you to practice commands and write shell programs, but
if you are not sure, get permission please. Above, when referring to
login as "root" and reinstalling the system in the event you forgot
your password, I mean do that ONLY IF the computer is yours (ie,
you own it). Also, I advise you to get a FREE version. There is no
need to pay anything, especially for learning purposes. With a free
version, if for some reason you completely mess up the system and you
cannot reinstall it, if your cd melts, breaks, gets lost, whatever,
you can get another copy of the system for free with no financial loss
to you. If you are not sure as to where to get a free copy, email me.
I am reluctant to suggest any particular site to you, since it would
be more beneficial to you if you performed a search yourself. The
information would then be more "valuable" to you and you would be
more eager to learn. If anyone has some suggestions that they would
like to share with your fellows, please email me.
Finally, although it would be useful to have access to a UNIX/Linux
system, it is not necessarily a requirement (basically, I leave it
up to you).
(Lecture continued after this important
sponsor break…)
From THE ONE STOP GAME SHOP
The Holidays are just around the corner and you
know what that means… time to shop for the latest
game releases from DreamCast, Gameboy, Nintendo,
Playstation One and Two, PC Games, Strategy Games
and all the rest. We offer the widest selection at
the best prices. Come and see, you and yours will
be glad you did!
http://www.vstore.com/vstoregames/1stopgameshop
(This week’s lecture continued…)
I think that will be all for this lecture. If you found some of the
things in this lecture confusing, there is no need to worry. You
are not required (nor is it expected) to understand everything the
first time. Few people understand things the first time they encounter
them.
A proverb for you: "The appetite comes during the meal."
Best Wishes and Health to You,
Vladimir Polyakov
P.S. Many people have not yet confirmed their desire to receive this
newsletter/lecture via the email I told you about (called "UNIX
Lecture" with the link inside). Please do so at your earliest
convenience, it would save me much time and make the mailing of these
lectures much easier and efficient.
P.P.S. And a special thanks to the Russian News Network for their
help in this endeavor.
http://www.russiannewsnetwork.com