
Basic
Commands
What is
Unix
Logging
in
Command
basics
Various
useful commands
Archaic
stuff
I/O
Redirection, Metacharacters, and Pipes
Customization
Logging
out
Reading:
The Unix Programming Environment, Chapter 1
- Just what makes a system
"Unix" anyway?
- Officially
"branded" by SCO?
- Note that Linux and
FreeBSD are not "branded Unix."
- A timesharing system
with certain features?
- Is it the kernel, or
the command line utilities as well?
- Can you come up with
a definition that distinguishes Unix from Windows 2000 with the Cygwin package installed?
- An untechnical person
has a Mac laptop that runs on MacOS X, but he never uses the command
line. Is he a Unix user?
- The authors of The Unix
Programming Environment allow for various interpretations and say, in
essence, if it looks like a duck and you feel like calling it a duck, go
ahead and call it a duck.
- They expect you to
figure out from the context what "Unix" means in any particular
sentence.
- Whatever you call it, Unix
can be rather intimidating, but an understanding of some fundamental
philosophies and familiarity with a handful of commands (i.e. passing this
course) will help you tap its power.
- Remember that Unix was
designed by programmers for programmers, so many of its features are
there to help programmers.
- Unix is a multiuser system
(meaning that many different users may use the same system), so users must
identify themselves.
- Authentication (proving who
you are) is done with a login name and a password.
- Protecting your
password is important because it's the "key" to who you are on
the computer.
- After successfully
authenticating yourself, some setup is done in the background (using shell
scripts, which we'll talk about later in the semester), and you are given
a "shell prompt".
- This is the place
where you give Unix commands and get results back
- Note that we're talking about
a text login here. GUI login is a bit different.
- Commands are entered by
typing them at the command line.
- An end of line (entered with
the return key) tells Unix (actually your shell) to go ahead and interpret
the line of text, and do whatever it says.
- Simple examples
- Shows the current
date and time
- Shows who is
currently logged in
- Shows the last number
of users to log in
- This is actually
useful sometimes!
(For varying degrees of "useful".)
- This command is a
simple way to send a message to someone else.
- Think of it as a 1970s
version of instant messaging.
- Allows you to read
"man pages"
- The term "man
page" refers to the days when the Unix manual was printed, and each
command or system call got its own page (or often pages), thus it was a
"man page."
- The same reference was
provided in electronic form, and the same name stuck
- Standard format
- More reference than
tutorial
- Iterate!
- Read the man page
- Try the command
- Read the man page
again, understand a little more
- Try the command again
- etc.
- Use man -k to look for
commands
- Use the "See
also" section to find other related commands; sort of a primitive
hypertext system
- You will use this
often, to check on the existence of files and view their metadata
(permissions, modification time, etc).
- If you don't already
know it, spend some time to get familiar with the format of ls -l.
- A couple of nice
"view a screen of text at a time" utilities. less is more capable than more.
- let you view just the
beginning or ending of a file
- Shows you the
differences between two files, in a format that seems cryptic until you
understand it.
- “Echoes” (prints) the
command line to the output output
- You should be familiar with
the commands in Table 1.1 on page 22 of The Unix Programming
Environment.
- The Unix Programming
Environment discusses the use of the '#' and '@' characters for
undoing mistakes in your typing. That is archaic and dates from the days
before 101-key keyboards, specifically before the control key was common.
- Nowdays, typing '#'
and '@' probably gives you a '#' or an '@'
- The book also says you can
cancel most commands with the delete or break keys
- This is probably
"^C" on whatever system you're using
- "^C" is the
conventional way to write "control-C", i.e. hold down the
control key and type "C".
- Pay no attention to
what the book says about reading or sending mail
- Once upon a time, the mail command, as described in the
book was the only way to do it.
- Trust me, you'd
rather use pine, elm, mutt, or just about any other mail command
- This was a simple way
to inform users of things they ought to know
- That function is now
performed by email
- Do not confuse the news command with
"netnews" aka. "usenet"
- The Unix
Programming Environment describes ed
as "universally available, efficient, and effective." Read up
on it only to have a laugh at the old-timers who actually had to use ed on a daily basis.
- We'll get into each of these
topics when we get to Chapter 3
- It might be worth reading the
discussion here in Chapter 1, to get ready for the full discussion in
Chapter 3.
- The treatment here is very brief,
but the things mentioned here, especially stty,
are still useful.
- For some sadistic reason, the
computer world has burdened us with two different possible characters
coming from the "backspace" key, and you will eventually
encounter a system that uses the opposite one from what you're using.
- The stty erase command is your key to
dealing with this
- The book talks about changing
.profile to customize your
setup.
- That is true for the
Bourne Shell, and others derived from it
- Korn Shell (ksh),
Bourne-Again Shell (bash), etc.
- C-shell (csh) and it's
derivatives use .login
- You start a Unix session by
logging in, you end it by logging out
- The book says "^D"
is the best way to log out.
- But "exit"
and/or "logout" also work, and are preferred by some shells