Geek City:
Unix under the Hood of the Mac OS X
Peter Roll
Sun City TX Computer Club
Advanced Technology SIG
March 18, 2003



Summary: topics to be covered
1. Where it came from and how it got in under the Mac operating
system (a little history...)
- Developed by computer scientists at
Bell Labs in 1969, for minicomputers (new) for basic science and
engineering research; handled numerical calculations, text manipulation,
and all sorts of symbol-processing.
- UC Berkeley Computer Science
Department extended and developed a new dialect of Unix during the 1970's,
which came to be called the Berkeley Software Distribution (BSD Unix).
- Government agencies, the computer
industry, and foreign governments wanted a standard version of Unix that
would always produce identical results for calculations.
- Computer scientists representing the
profession and these groups defined the Posix standard for Unix;
the Berkeley Computer Science Department made its BSD Unix the first
implementation of Posix.
- In the meantime, many computer
manufacturers devised their own proprietary operating systems and versions
of Unix, and the Posix standard has largely been forgotten.
- When Steve Jobs was fired as President
of Apple Computer in 1986, he founded the Next Computer company.
- Next developed a computer system using
Motorola processors and the NextStep operating system based on BSD Unix
with an advanced graphical user interface and application development
system.
- Later, Next ported the NextStep OS to
run on standard Intel-based PC computers, thus enlarging their potential
market.
- By the time Apple purchased Next in
1997, Apple had begun allowing 3rd parties to build and sell Mac-OS-based
computers and had started a project, code-named Copland, to develop
a new operating system eliminating some of the limitations built into the
original Mac OS.
- Shortly after Apple purchased Next,
Steve Jobs was named Interim President; his two major actions were to
discontinue allowing Mac clones to be sold; and to initiate a review of
the Copland project.
- Jobs and the senior technical staff
brought over from Next concluded that the Copland project would fail.
- They developed an alternative OS
strategy based on the NextStep approach, using BSD Unix as the foundation
of the new OS and building an entirely new graphical user interface on top
of it.
- The most difficult problem in
developing the new OS (Copland or NextStep-based) was to allow old Mac
proglrams to continue to function under the new OS, knowing this would be
required while users adapted and accepted the new OS and developers
rewrote their application programs.
- The solution to this problem was to
allow old Mac OS to run under the new OS in so-called "classic
mode," thus preserving the look-and-feel of the old OS and the
functionality of the old programs.
Why
Unix? What does it do that other PC OS's didn't do (Windows and Mac)?
Pre-emptive
multitasking and protected memory:
prevents one program or process from interfering with memory utilization of
another, thus preventing crashes and simplifying application program design.
Multiprocessor support: allows use of two or more processors by
the same task, thus making the computer faster.
Scalability: work the same way on the smallest and largest
systems available, with minimum ormaximum feature sets, all sorts of
peripherals, protected memory, multiprocessing, threaded processes; from the
smallest, most primitive micros to parallel-processing supercomputers
with hundreds of processors.
Return to
Top
2.
How it's put together (a little architecture...)
... with apologies to the Computer Science profession ...

... and with apologies to Apple Computer Corp. ...

Some important characteristics of Unix operating systems:
- settings controlled by small
text-based files
- settings files created and changed
with simple text editor
- highly-coded text,
- so its easy to read and change (for
anybody who knows the code!)
- easy to learn (for those who learn
codes easily!)
- and it led to a weird
jargon, including the word Geek
- and ... the most important
characteristics of
- preemptive multitasking,
- protected memory,
- multiprocessor support
- scalability
Return to
Top
3.
How it works (scratching the surface just a little...)
a. Important notes:
- Unix is case-sensitive
- not consistently, but when you least
expect it and when it is most annoying or damaging
- convention: always use lower-case
characters
b. Anatomy of a Terminal window, on opening (login):
|
Last login: Sun Mar 16 15:03:06 on ttyp1
Welcome to Darwin!
[Peter-Rolls-Computer:~] proll%
|
Date, time, device
Welcome
[Name of computer: active directory] username
|
c. Some definitions:
|
Unix directory
|
a folder in Mac or Windows lingo
|
|
Active directory
|
the one that all the action will take place in at any
given time
|
|
root directory
|
at the root or top level of the hard disk
|
|
root directory
|
/
|
|
active user account home directory
|
~
|
|
pathnames in the file
|
|
|
full pathname, e.g.
|
/Users/proll/Documents
|
|
pathname relative to active directory
|
/Documents
|
|
pathname relative to active user home directory
|
~/Documents
|
|
down one level in file system hierarchy
|
/dirname
|
|
up one level in the file system hierarchy (parent
directory)
|
../
|
|
change active directory command
|
cd pathname (note the space as a delimiter!)
|
d. The Unix File system
The file system under Mac OS X (column view, similar to Windows Explorer
-- shows relative position of files and folders):

The actual file structure under Unix contains much more at the root level
than is shown in the OSX finder!
|
[Peter-Rolls-Computer:~]
proll% ls
100NIKON
Documents
Music
Send Registration
Applications
Library
Pictures
Sites
Desktop
Movies
Public
[Peter-Rolls-Computer:~] proll%
[Peter-Rolls-Computer:~] proll% cd /
[Peter-Rolls-Computer:/] proll% ls
???Move&Rename
System
etc
AppleShare PDS
TheVolumeSettingsFolder mach
Applications
Trash
mach.sym
Desktop
DB
Users
mach_kernel
Desktop
DF
Volumes
private
Desktop
Folder automount
sbin
Library
bin
tmp
Network
cores
usr
Resources
dev
var
[Peter-Rolls-Computer:/] proll% cd ~/documents
[Peter-Rolls-Computer:~/documents] proll% cd ~/Documents
[Peter-Rolls-Computer:~/Documents] proll% ls
8:27:02Apps.10.1.5.tiff
Neighborhod#2.lst
ACO
Neighborhood 2 DIR-2
Acrobat User
Data
Neighborhood 2 Dir
AppleWorks User
Data
NewBookmarks.html
BackupStuff
NewBookmarks.html~
CD-RWSuppt.rtf
Notes
CompClub
OSXInfo
ComputerIcons.cwk
OnlineOrders
DVixDir.rtfd
PIE.SCGT
Email file (generic)
#13726
Palm
Eudora
Folder
Palmcopy020205
FAXReceive
Personal:Family
FloorPlan0211.gif
Peter.fs
GCN
Quintet
GISDTechn.Cte
RouterRef1.rtf
GIVE
SchoolTaxDoc98.01
Gtwn+
Science
IDs.rtf
ServicesReadMes
IDsMaster.rtf
ShowCase030218a.tiff
ISPFAQ
SrUniv
InstallFiles
TB2MsgsRcvd
InventoryTempl.sylk
WebSites
JohnsExcel
WoodShop
MAIN
eGtwn
MacNews0201.rtf
emailadrses030102.bk
Microsoft User
Data
iNotePad User Data
MiscRecFiles
index3.html
Move:Retirement.95
[Peter-Rolls-Computer:~/Documents] proll%
|
What's found in this Terminal window:
- initial active directory is active
user's home directory (~)
- ls is the shell command to list the
contents of the active directory
- cd / changes the active directory to
root
- ls lists the contents of the root
directory; note that there are several files listed that are missing from
the OS X finder window -- these Unix directories are unneeded in OS X and
they are hidden, visible only in the Terminal window
- cd ~/documents changes the active
directory to the Documents directory in the active user's home directory
- note that the case of the first letter
of the word directory doesn't make any difference!
- ls lists the files and directories in
the active user's Documents director
Some notes on the File system, Unix
and OS X:
/Users/proll/documents/Compclub is
the full path to my Computer Club folder; and that
~/Documents/Compclub is exactly the same path.
All info for a given user (settings, documents, etc.) is stored in the User
Account Home directory (or folder) (similar to the Documents and Settings
folder in Windows XP).
In the directory /Users/proll/ (same as ~/)
- the Documents directory-folder
contains all user documents and other data (but you have to keep it this
way!)
- ~/ Library directory-folder
contains preferences or settings applicable only to the active user
account
- the /Library directory-folder contains
preferences or settings applicable to all user accounts
Applications
available for use by all user accounts are stored in the root /Applications
directory-folder
Appllications available for use only by a given user are stored within the
user's home directory-folder, ~/Applications
Return to
Top
e. A few of the Unix Services:
(1) The Unix Shell: the tcsh shell is default for OS X
- but many other shells are available
- all shells are pretty similar -- they
work the same way but have minor differences
- you can install other shells on OS X
if you wish
(2)
Some shell commands (Unix utility programs):
General format of shell commands:
commandname options arguments
·
Note that the spaces are essential
delimiters
·
options are of the format -x, where x
is a code letter for an option
How do you find out what the
commands do and what the options are?
·
type the command man commandname
·
this displays the Unix manual page for
the specified command -- try it!
(3) Some commands or services
we've already seen (above):
·
ls
·
cd
·
man
·
ls -la (list showing details (l) and
hidden files (a))
|
Last login: Sun
Mar 16 16:33:30 on ttyp1
Welcome to Darwin!
[Peter-Rolls-Computer:~] proll% cd /
[Peter-Rolls-Computer:/] proll% ls
???Move&Rename
System
etc
AppleShare PDS
TheVolumeSettingsFolder mach
Applications
Trash
mach.sym
Desktop
DB
Users
mach_kernel
Desktop
DF
Volumes
private
Desktop
Folder
automount
sbin
Library
bin
tmp
Network
cores
usr
Resources
dev
var
[Peter-Rolls-Computer:/] proll% ls -la
total 11273
drwxr-xr-x 2 proll
unknown 68 Jan 2 17:01
???Move&Rename
drwxr-xr-x 34 proll staff
1156 Mar 16 14:37 .
drwxr-xr-x 34 proll staff
1156 Mar 16 14:37 ..
-rwxr-xr-x 1 proll staff
12292 Mar 16 14:37 .DS_Store
d-wx-wx-wx 3 root unknown
102 Sep 2 2002 .Trashes
-r--r--r-- 1 root
wheel 156 Jul 14 2002 .hidden
dr--r--r-- 2 root
wheel 160 Mar 16 11:21 .vol
-rwxr-xr-x 1 proll unknown 323584 Feb 27 02:35
AppleShare PDS
drwxrwxr-x 53 root
admin 1802 Feb 26 20:14 Applications
-rw-r--r-- 1 root admin
119296 Mar 16 13:36 Desktop DB
-rw-r--r-- 1 root admin
841458 Mar 15 10:21 Desktop DF
drwxr-xr-x 2 proll
unknown 68 Dec 20 21:51 Desktop Folder
drwxrwxr-x 32 root
admin 1088 Feb 27 20:42 Library
drwxr-xr-x 6 root
wheel 204 Aug 31 2002 Network
drwxr-xr-x 4 root
staff 136 Mar 14 14:03 Resources
drwxr-xr-x 4 root
wheel 136 Dec 15 03:07 System
drwxr-xr-x 3 proll unknown
102 Dec 20 21:51 TheVolumeSettingsFolder
drwxr-xr-x 2 proll
unknown 68 Dec 20 21:51 Trash
drwxrwxr-t 5 root
wheel 170 Aug 31 2002 Users
drwxrwxrwt 5 root
wheel 170 Mar 16 11:21 Volumes
dr-xr-xr-x 1 root
wheel 512 Mar 16 17:08 automount
drwxr-xr-x 35 root
wheel 1190 Jan 25 12:19 bin
drwxrwxrwt 2 root
wheel 68 Jul 14 2002
cores
dr-xr-xr-x 2 root
wheel 512 Mar 16 11:21 dev
lrwxr-xr-x 1 proll
staff 11 Mar 16 14:37 etc
-> private/etc
lrwxr-xr-x 1 proll
staff 9 Mar 16 14:37
mach -> /mach.sym
-r--r--r-- 1 root staff
706480 Mar 16 11:21 mach.sym
-rw-r--r-- 1 root wheel 3733424 Dec
14 05:11 mach_kernel
drwxr-xr-x 6 root
wheel 204 Mar 16 11:21 private
drwxr-xr-x 60 root
wheel 2040 Jan 25 12:19 sbin
lrwxr-xr-x 1 proll
staff 11 Mar 16 14:37 tmp
-> private/tmp
drwxr-xr-x 10 proll
staff 340 Mar 14 14:03 usr
lrwxr-xr-x 1 proll
staff 11 Mar 16 14:37 var
-> private/var
[Peter-Rolls-Computer:/] proll%
|
Some other useful commands:
Finding things on your hard disk: locate pattern
- pattern is a string of characters that
can be contained in a filename or directoryname; the command will find all
files and directories with that string in its name;
- a database of file- and directorynames
must be created before the locate command will work; this database is
created by the command
sudo
/usr/libexec/locate.updatedb (note: this took about 5 minutes to
complete on my computer);
- use the man locate command to
find out more.
Printing and Piping:
enscript filename: converts a file to postscript for printing to a
postscript printer (most laser printers)
atprint filename: prints a file to an AppleTalk printer; this command
must be set up first with the commands
- atlookup to find all of the
AppleTalk devices connected to the computer, followed by the superu
command
- sudo at_cho_prn to select the
device you want to use to print (lyou need the superuser or root password
for this one).
If
the AppleTalk printer is a postscript printer, then you must convert it to
postscript before sending to the printer. The way to do this is to Unix's piping
capability: the pipe symbol | will pipe the output of one command into
the input of the next; e.g., to print the manual page for the locate command,
man locate | enscript | atprint
Shell scripting, aka shell programming: the Unix alias:
|
[Peter-Rolls-Computer:~] proll% ls
100NIKON
Documents
Music
Send Registration
Applications
Library
Pictures
Sites
Desktop
Movies
Public
[Peter-Rolls-Computer:~] proll% alias ls "/bin/ls -al"
[Peter-Rolls-Computer:~] proll% ls
total 56
drwxr-xr-x 17 proll staff 578 Mar 16 14:37
.
drwxrwxr-t 5 root wheel 170 Aug 31 2002 ..
-rw-r--r-- 1 proll staff 3
Dec 26 20:28 .CFUserTextEncoding
-rwxr-xr-x 1 proll staff 12292 Mar 16 14:37 .DS_Store
drwx------ 13 proll staff 442 Mar 16 13:55
.Trash
-rw-r--r-- 1 proll staff 31 Mar 13
12:09 .lpoptions
drwxrwxrwx 10 proll staff 340 Dec 21 07:25
100NIKON
drwxr-xr-x 3 proll staff 102 Sep
3 2002 Applications
drwx------ 23 proll staff 782 Mar 16 14:37
Desktop
drwx------ 59 proll staff 2006 Mar 15 22:05 Documents
drwx------ 39 proll staff 1326 Feb 5 21:25
Library
drwx------ 4 proll staff 136 Jan 18 18:54
Movies
drwx------ 7 proll staff 238 Dec 18 13:03
Music
drwx------ 20 proll staff 680 Mar 15 17:35
Pictures
drwxr-xr-x 4 proll staff 136 Aug 31
2002 Public
lrwxr-xr-x 1 proll staff 55 Mar 16
14:37 Send Registration -> /Users/proll/Library/Assistants/Send
Registration.setup
drwxr-xr-x 5 proll staff 170 Aug 31
2002 Sites
|
Aliases
can be saved to the /bin/.cshrc text file so that they will always be
active. An alias is a little shell program; you can construct some very complex
programs this way!!
Return to
Top
4. What you can do with Unix if you're not a Geek:
normal applications software available
MS Office replacements:
- file compatibility with MS Word,
Excel, PowerPoint (Open and Save as...)
- usually run in the X11window, so you
need to install X11, too
- available for online download, often
at no cost (but 1xx MB, so it takes a while), with X11 and everything else
you need
- usually available on CD for $40-50,
with X11 and everything else you need
- Examples:
- OpenOffice
- ThinkFree Office (written in Java, so
it runs on every platform!)
Browsers:
- Netscape
- Mozilla
- Lynx (text-only, so it's fast, if
nothing else)
- others....
Utilities: thousands of these
One example: CarbonCopyCloner, by Mike Bombich
- a script invoking several pre-existing
Unix programs to make a bootable copy of a hard disk and to back up all or
parts of a hard disk to a variety of media (CD-R, a 2nd HD, etc.)
- downloadable giftware (pay the author
what you want if it's been usefult to you)
- simple -- it just works
- no comparable simple program for
Windows
The
Good News: thousands of programs available
at no cost, downloadable
The Bad News: most of them are designed for other Geeks, rather
than ordinary users,
but if there's something usable for just about every purpose if you are
willing to look and tolerate a little geekiness.
Return to
Top
5. The Geek's Business Model: the economics of Unix
The open-source movement -- an integral
part of Unix:
From the Apple Darwin
FAQ page:
Q. What is open source?
Open source is a term for the historical development model used by the
Internet community to facilitate distributed development of complex,
high-quality software. The basic principle is to involve as many people as
possible in writing and debugging code, by publishing the source code and
encouraging the formation of a large community of developers who will submit
modifications and enhancements. Community efforts such as BSD, Linux, Sendmail,
Apache, and Perl embody the spirit and power of the open source model.
Q. Why is Apple opening up its source?
We believe the open source model is the most effective form of development for
certain types of software. By pooling expertise with the open source
development community, we expect to improve the quality, performance and
feature set of our software.
Secondly, we realize many developers enjoy working with open source software,
and we want to provide them the opportunity to use that kind of environment
while delivering solutions for Apple customers.
The open-source movement is
- Diverse; based on several rather
different kinds of open-source licensing:
- Open Software Foundation; the GNU
license -- copyright; use requires that all derivative works go into
public domain and be distributed;Free Software Foundation's General
Public License (GPL),
- BSD license
- Apache license,
- Netscape and Mozilla Public Licenses
- Sun's Community Source License.
- Apple Public Source License
- Based on a fundamental difference
between the economics of goods and services and the economics of
information:
- goods and services: can be pounit
value is reduced or eliminated by consumption
- information: value is increased by
use and by the number of people using it; value is created by the
consumers
- may require new business models
and a new form of economics that is not yet understood or even much
studied
- Full of private and corporate
ideological agendas, most of which have little to do with the realities of
the world and how the future is likely to develop
The results of this information and
communications revolution and the surviving business and economic models
will become clear only after decades of evolution -- not in our lifetime.
What better name than Darwin for an operating system that grew out of the beginnings of
this revolution?
Return to
Top
6. A Few
References: Unix under Mac OS X
Taylor and
Peek, Learining Unix for Mac OS X; O'Reilly, Sebastopol, CA, 2002; 126 pgs.
O'Reilly is the definitive publisher of reference and textbooks on alll
varieties of the Unix OS; see their website
for many more useful references
Listing of Unix & Open-Source programs that will run on OSX Macs: http://www.apple.com/downloads/macosx/unix_open_source/
Apple's Open-source Darwin home page; explains briefly the concept
behind Apple's open-source approach and the architecture underneath OSX:
http://developer.apple.com/darwin/
The Fink Project " ... bringing the full world of Unix
Open Source software to Darwin and Mac OS X . We modify Unix software so that
it compiles and runs on Mac OS X ("port" it) and make it available
for download as a coherent distribution. Fink uses Debian tools like dpkg and
apt-get to provide powerful binary package management. You can choose whether
you want to download precompiled binary packages or build everything from
source." http://fink.sourceforge.net/
SourceForge.net: " ... the world's largest
Open Source software development website, with the largest
repository of Open Source code and applications available on the Internet.
SourceForge.net provides free services to Open Source developers." http://sourceforge.net/
Return to
Top