Introduction to Unix UW, Department of Astronomy November 30, 1998
What is Unix?
A Computer Operating System
Software which provides a consistent means for programs to
interact with the computer hardware
Provides for input, output, data storage and retrieval,
program execution
Also, the collection of applications and utilities
commonly installed on Unix systems
Created in 1969/70 at Bell Labs as an outgrowth of the 1965
Multics project
1963, Multics introduced the idea of multi-user,
multi-tasking, multi-processor OS with hierarchical
filesystem. Unix built on these ideas.
1969, the first Unix is written at AT&T Bell Labs
after AT&T drops out of the Multics project
Unix rewritten in C in 1973, introduced to the world in
1974 in an ACM article
AT&T prohibited from distributing Unix commercially by
antitrust consent decree
Grew to 100,000 sites worldwide by 1984 largely in
academia where source code was available
Many flavors evolved most based on
either BSD (academia) or SysV (commercial & Govt.). Most
differences are transparent to end users
Linux introduced in 1991 circumvented copyright
issues, leveraged the power of the Internet. Unix exploded in
popularity with desktop computer users.
First Step Logging in
Usernames are eight or fewer characters in length, and, by
convention, lower case
Passwords are essential to system security they
should
ALWAYS:
Be eight characters long
Be a mix of letters in upper
and lower case, numerals, and punctuation
NEVER:
Be in any dictionary
Be a proper noun
Use repeating sets of
characters
The Shell - Primary User Interface to the Computer
Two Main Alternatives
Sh the bourne shell
The original shell available on all Unix systems
Awkward in its original implementation, but newer
varieties such as ksh and, especially, bash are a
pleasure to use.
Provides a Complete Programming Environment:
Variables, conditionals, loops, etc.
Most system shell scripts are written in bourne shell
Usually uses a $ prompt
Csh the C shell
Available on most systems
Written to provide a more familiar interactive
environment for C programmers
Provides a Complete Programming Environment:
Variables, conditionals, loops, etc.
Powerful variations are available e.g. tcsh, zcsh,
etc.
Usually uses a % prompt
Unix is more than the base OS
or kernel. It is a collection of hundreds of small programs,
developed and refined over time to make the computer a productive
tool. Orthogonality, combined with mechanisms for combining
commands makes for a powerful environment.
Navigating the File System
A hierarchical tree with a root /,
branches, and leaves
Where am I? pwd print working
directory
Whats here? ls list the contents
-l the long listing
Permissions for Owner, Group, and Other
Read, Write, Execute
-a Show hidden files
. The current directory
.. The parent directory
Globbing - *?[
"*" substitutes for zero or more characters
"?" substitutes for any single character
"[]" encloses a character 'class' (eg. [0-9] or
[a-z])
Moving About with cd
Absolute and Relative Paths
Absolute paths begin at the root - i.e with a "/"
Relative paths begin with the current directory
Use the double dots ".." to move upward in the tree
with relative addressing
Using Shortcuts
The Twiddle
'~/' is a shortcut to your home dir
'~/someuser' is a shortcut to someuser's home dir
The Dots
'cd ..' moves up one level in the directory tree
'cd ../..' moves up two levels
Creating and Removing Files and Directories
mkdir
Redirection a hint at the power of Unix
'echo sometext > somefile'
'date > datefile'
'date >> datefile'
rm, and rmdir Be Careful!!
Looking at What Youve Got
cat and more
head and tail
Getting Help from the MANual
How to Ask When You Dont Know the Question
apropos & man k
whatis
The Sections
1 User Commands
2 Programmers Manual
system calls
3 Programmers Manual functions
4 Special Files
5 Config Files
8 Sysadmin Commands
Editing Text Files with Emacs and Vi
VI you cant escape it
Available on every Unix system
Modal Youre either entering commands or
editing
Similar commands are used in many other system tools
descended from common ancestry sed, ed, etc.
A Command Overview
Inserting Text
i is for INSERT, a is
for APPEND
o is for OPEN a line below,
O is for OPEN above
Deleting Text
x is for EXPUNGE
dd is for DELTE LINE
Cursor Movement
h moves LEFT
l moves RIGHT
k moves UP
j moves DOWN
$ moves to the end of the line
0 (zero) moves to the
beginning of the line
G moves to the end of the file
:0 moves to the beginning
Saving and Quitting
:w WRITES a file
:q QUITS
:wq WRITES & QUITS
:q! QUITS, not questions asked!
Emacs all things
to all people
Available on most systems
Infinitely extendable read mail, diagnose your
psychoses, etc.
Developed by the GNU folks by programmers, for programmers
Similar commands are used in other editors notably
Pico, the 'Pine' editor
Supports X Windows
Uses Control (the <Ctrl> key) and Meta-key (usually
<Escape>) to distinguish commands from input
A Command Overview
Cursor Movement
C-f move FORWARD one character
C-b move BACKWARD one character
C-P move to the PREVIOUS line
C-n move to the NEXT line
C-a move to the BENNING of the line
C-e move to the END of the line
C-x[ move to the beginning of the FILE
C-x] move to the end of the FILE
Deleting Text
C-d DELETES a Character
M-d DELETES a Word
C-k KILLS a Line
Retrieving Text
C-y YANKS the Kill Buffer
Formatting Text
M-q REFORMATS a paragraph
Saving and Quitting
C-x C-s SAVES a file
C-x C-c QUITS
Seeing the Doctor
M-x doctor
<return>
Introduction to Unix, UW Astronomy, November 2, 1998
10