blob: 9cab9cbffac4d81708dc2a07f397b9774c6dff32 [file] [log] [blame]
rscc8b63422005-01-13 04:49:19 +00001.TH INTRO 1
2.SH NAME
3intro \- introduction to Plan 9 from User Space
4.SH DESCRIPTION
5Plan 9 is a distributed computing environment built
6at Bell Labs starting in the late 1980s.
7The system can be obtained from Bell Labs at
8.B http://plan9.bell-labs.com/plan9
9and runs on PCs and a variety of other platforms.
10Plan 9 became a convenient platform for experimenting
11with new ideas, applications, and services.
12.PP
13Plan 9 from User Space provides many of the ideas,
14applications, and services from Plan 9
15on Unix-like systems.
16It runs on
17FreeBSD (x86),
18Linux (x86 and PowerPC),
19Mac OS X (PowerPC),
20OpenBSD (x86),
21and
22SunOS (Sparc).
23.SS Commands
24Plan 9 from User Space expects its own directory tree,
25conventionally
26.BR /usr/local/plan9 .
27When programs need to access files in the tree,
28they expect the
29.B $PLAN9
30environment variable
31to contain the name of the root of the tree.
32See
rsc93aa30a2005-01-14 03:27:51 +000033.IR install (1)
rscc8b63422005-01-13 04:49:19 +000034for details about installation.
35.PP
36Many of the familiar Unix commands,
37for example
38.IR cat (1),
39.IR ls (1),
40and
41.IR wc (1),
42are present, but in their Plan 9 forms:
43.I cat
rsc1ba05242005-01-14 23:46:18 +000044takes no options,
rscc8b63422005-01-13 04:49:19 +000045.I ls
46does not columnate its output when printing to a terminal,
47and
48.I wc
49counts UTF characters.
50In some cases, the differences are quite noticeable:
51.IR grep (1)
52and
53.IR sed (1)
54expect Plan 9 regular expressions
55(see
56.IR regexp (7)),
57which are closest to what Unix calls extended regular expressions.
58Because of these differences, it is not recommended to put
59.B $PLAN9/bin
60before the usual system
61.B bin
62directories in your search path.
63Instead, put it at the end of your path and use the
64.IR 9 (1)
65script when you want to invoke the Plan 9 version of a
66traditional Unix command.
67.PP
68Occasionally the Plan 9 programs have been
69changed to adapt to Unix.
70.IR Mk (1)
71now allows mkfiles to choose their own shell,
72and
73.IR rc (1)
74has a
75.I ulimit
76builtin and manages
77.BR $PATH .
78.PP
79Many of the graphical programs from Plan 9 are present,
80including
81.IR sam (1)
82and
83.IR acme (1).
84An X11 window manager
85.IR rio (1)
86mimics Plan 9's window system, with command windows
87implemented by the external program
88.IR 9term (1).
89Following the style of X Windows, these programs run in new
90windows rather than the one in which they are invoked.
91They all take a
92.B -W
93option to specify the size and placement of the new window.
94The argument is one of
95\fIwidth\^\^\fLx\fI\^\^height\fR,
96\fIwidth\^\^\fLx\fI\^\^height\^\^\fL@\fI\^\^xmin\fL,\fIxmax\fR,
97\fL'\fIxmin ymin xmax ymax\fL'\fR,
98\fRor
99\fIxmin\fL,\fIymin\fL,\fIxmax\fL,\fIymax\fR.
100.PP
101The
102.IR plumber (4)
103helps to connect the various Plan 9 programs together,
104and fittings like
105.IR web (1)
106connect it to external programs such as web browsers;
107one can click on a URL in
108.I acme
109and see the page load in
110.IR Firefox .
111.SS User-level file servers
112In Plan 9, user-level file servers present file trees via the Plan 9 file protocol, 9P.
113Processes can mount arbitrary file servers and customize their own name spaces.
114These facilities are used to connect programs. Clients interact
115with file servers by reading and writing files.
116.PP
117This cannot be done directly on Unix.
118Instead the servers listen for 9P connections on Unix domain sockets;
119clients connect to these sockets and speak 9P directly using the
120.IR 9pclient (3)
121library.
122.IR Intro (4)
123tells more of the story.
124The effect is not as clean as on Plan 9, but it gets the job done
125and still provides a uniform and easy-to-understand mechanism.
126The
127.IR 9p (1)
128client can be used in shell scripts or by hand to carry out
129simple interactions with servers.
rsc86a1a5e2005-07-19 17:58:26 +0000130.IR Netfiles (1)
131is an experimental client for acme.
rsc93aa30a2005-01-14 03:27:51 +0000132.SS External databases
133Some programs rely on large databases that would be
134cumbersome to include in every release.
135Scripts are provided that download these databases separately.
136These databases can be downloaded separately.
137See
138.B $PLAN9/dict/README
139and
140.BR $PLAN9/sky/README .
rscc8b63422005-01-13 04:49:19 +0000141.SS Programming
142The shell scripts
143.I 9c
144and
145.I 9l
146(see
147.IR 9c (1))
148provide a simple interface to the underlying system compiler and linker,
149similar to the
150.I 2c
151and
152.I 2l
153families on Plan 9.
154.I 9c
155compiles source files, and
156.I 9l
157links object files into executables.
158When using Plan 9 libraries,
159.I 9l
160infers the correct set of libraries from the object files,
161so that no
162.B -l
163options are needed.
164.PP
165The only way to write multithreaded programs is to use the
166.IR thread (3)
167library.
168.IR Rfork (3)
169exists but is not as capable as on Plan 9.
170There are many unfortunate by necessary preprocessor
171diversions to make Plan 9 and Unix libraries coexist.
172See
173.IR intro (3)
174for details.
175.PP
176The debuggers
177.IR acid (1)
178and
179.IR db (1)
180and the debugging library
181.IR mach (3)
182are works in progress.
183They are platform-independent, so that x86 Linux core dumps
184can be inspected on PowerPC Mac OS X machines,
185but they are also fairly incomplete.
186The x86 target is the most mature; initial PowerPC support
187exists; and other targets are unimplemented.
188The debuggers can only inspect, not manipulate, target processes.
189Support for operating system threads and for 64-bit architectures
190needs to be rethought.
191On x86 Linux systems,
192.I acid
193and
194.I db
195can be relied upon to produce reasonable stack traces
196(often in cases when GNU
197.I gdb
198cannot)
199and dump data structures,
200but that it is the extent to which they have been developed and exercised.
rscc8b63422005-01-13 04:49:19 +0000201.SS Porting programs
202The vast majority of the familiar Plan 9 programs
203have been ported, including the Unicode-aware
204.IR troff (1).
205.PP
206Of the more recent additions to Plan 9,
rsc26ca53e2005-02-14 00:37:51 +0000207.IR factotum (4),
208.IR secstore (1),
209and
rsc86a1a5e2005-07-19 17:58:26 +0000210.IR secstored (1),
211.IR vac (1),
212.IR vacfs (4),
rscfdf67c12005-01-16 23:01:55 +0000213and
rsc86a1a5e2005-07-19 17:58:26 +0000214.IR venti (8)
215are all ported.
rscc8b63422005-01-13 04:49:19 +0000216.PP
217A backup system providing a dump file system built atop Venti
rsc86a1a5e2005-07-19 17:58:26 +0000218is in progress; see
219.IR vbackup (8).
rscc8b63422005-01-13 04:49:19 +0000220.SS Porting to new systems
221Porting the tree to new operating systems or architectures
222should be straightforward, as system-specific code has been
223kept to a minimum.
224The largest pieces of system-specific code are
225.BR <u.h> ,
226which must include the right system files and
227set up the right integer type definitions,
228and
229.IR libthread ,
230which must implement spin locks, operating system thread
231creation, and context switching routines.
232Portable implementations of these using
233.B <pthread.h>
234and
235.B <ucontext.h>
236already exist. If your system supports them, you may not
237need to write any system specific code at all.
238.PP
239There are other smaller system dependencies,
240such as the terminal handling code in
241.IR 9term (1)
242and the implementation of
243.IR getcallerpc (3),
244but these are usually simple and are not on the critical
245path for getting the system up and running.
rsc93aa30a2005-01-14 03:27:51 +0000246.SH SEE ALSO
247The rest of this manual describes Plan 9 from User Space.
rscc8b63422005-01-13 04:49:19 +0000248Many of the man pages have been brought from Plan 9,
249but they have been updated, and others have been written from scratch.
250.PP
251The manual pages are in a Unix style tree, with names like
252.B $PLAN9/man/man1/cat.1
253instead of Plan 9's simpler
254.BR $PLAN9/man/1/cat ,
255so that the Unix
256.IR man (1)
257utility can handle it.
258Some systems, for example Debian Linux,
259deduce the man page locations from the search path, so that
260adding
261.B $PLAN9/bin
262to your path is sufficient to cause
263.B $PLAN9/man
264to be consulted for manual pages using the system
265.IR man .
266On other systems, or to look at manual pages with the
267same name as a system page,
268invoke the Plan 9
269.I man
270directly, as in
271.B 9
272.B man
273.BR cat .
274.PP
275The manual sections follow the Unix numbering conventions,
276not the Plan 9 ones.
277.PP
rsc93aa30a2005-01-14 03:27:51 +0000278.HR ../man1 "Section (1)
279describes general publicly accessible commands.
rscc8b63422005-01-13 04:49:19 +0000280.PP
rsc93aa30a2005-01-14 03:27:51 +0000281.HR ../man3 "Section (3)
282describes C library functions.
rscc8b63422005-01-13 04:49:19 +0000283.PP
rsc93aa30a2005-01-14 03:27:51 +0000284.HR ../man4 "Section (4)
285describes user-level file servers.
rscc8b63422005-01-13 04:49:19 +0000286.PP
rsc93aa30a2005-01-14 03:27:51 +0000287.HR ../man7 "Section (7)
288describes file formats and protocols.
rscc8b63422005-01-13 04:49:19 +0000289(On Unix, section (5) is technically for file formats but
290seems now to be used for describing specific files.)
rsc86a1a5e2005-07-19 17:58:26 +0000291.PP
292.HR ../man8 "Section (8)
293describes commands used for system administration.
rscc8b63422005-01-13 04:49:19 +0000294.PP
rsc93aa30a2005-01-14 03:27:51 +0000295.HR ../man9 "Section (9p)
296describes the Plan 9 file protocol 9P.
rsc01cd4062005-01-14 19:43:51 +0000297.PP
298These pages describe parts of the system
299that are new or different from Plan 9 from Bell Labs:
300.IP
301.IR 9 (1),
302.IR 9c (1),
303.IR 9p (1),
304.IR 9term (1),
305.I acidtypes
306in
307.IR acid (1),
308.IR cvs (1),
309.IR dial (1),
310.IR label (1),
311the
312.B MKSHELL
313variable in
314.IR mk (1),
315.IR namespace (1),
rsc3aec33f2005-07-18 22:41:58 +0000316.IR netfiles (1),
rsc01cd4062005-01-14 19:43:51 +0000317.IR page (1),
318.IR psfonts (1),
319.IR rio (1),
320.IR web (1),
321.IR wintext (1)
322.IP
323.IR intro (3),
324.IR 9pclient (3),
325the
326.B unix
327network in
328.IR dial (3),
329.IR exits (3),
330.IR get9root (3),
331.IR getns (3),
332.IR notify (3),
333.IR post9pservice (3),
334.IR rfork (3),
rscde398602005-01-23 23:19:47 +0000335.IR searchpath (3),
rsc01cd4062005-01-14 19:43:51 +0000336.IR sendfd (3),
337.IR udpread (3),
rsc86a1a5e2005-07-19 17:58:26 +0000338.IR venti (3),
rsc01cd4062005-01-14 19:43:51 +0000339.IR wait (3),
340.IR wctl (3)
341.IP
342.IR intro (4),
343.IR 9pserve (4),
rsc86a1a5e2005-07-19 17:58:26 +0000344.IR import (4),
345.IP
346.IR vbackup (8)
rsc01cd4062005-01-14 19:43:51 +0000347.IP
348.IR openfd (9p)
rscc8b63422005-01-13 04:49:19 +0000349.SH DIAGNOSTICS
350In Plan 9, a program's exit status is an arbitrary text string,
351while on Unix it is an integer.
352Section (1) of this manual describes commands as though they
353exit with string statuses. In fact, exiting with an empty status
354corresponds to exiting with status 0,
355and exiting with any non-empty string corresponds to exiting with status 1.
356See
357.IR exits (3).