1
0

0intro 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. .TH INTRO 1
  2. .SH NAME
  3. intro \- introduction to Plan 9
  4. .SH DESCRIPTION
  5. Plan 9 is a distributed computing environment assembled from
  6. separate machines acting as terminals,
  7. CPU servers, and file servers.
  8. A user works at a terminal, running a window system on a raster display.
  9. Some windows are connected to CPU servers; the intent is that heavy computing
  10. should be done in those windows but it is also possible to compute on the terminal.
  11. A separate file server provides file storage for terminals and
  12. CPU servers alike.
  13. .SS Name Spaces
  14. In Plan 9, almost all objects look like files.
  15. The object retrieved by a given name is determined by a mapping called the
  16. .IR "name space" .
  17. A quick tour of the standard name space is in
  18. .IR namespace (4).
  19. Every program running in Plan 9 belongs to a
  20. .I process group
  21. (see
  22. .I rfork
  23. in
  24. .IR fork (2)),
  25. and the name space for each process group can be independently
  26. customized.
  27. .PP
  28. A name space is hierarchically structured.
  29. A full file name (also called a
  30. .IR "full path name" )
  31. has the form
  32. .IP
  33. .RI / e1 / e2 /.../ en
  34. .PP
  35. This represents an object in a tree of files: the tree has a root,
  36. represented by the first
  37. .LR / ;
  38. the root has a child file named
  39. .IR e1 ,
  40. which in turn has child
  41. .IR e2 ,
  42. and so on; the descendent
  43. .I en
  44. is the object represented by the path name.
  45. .PP
  46. There are a number of Plan 9
  47. .I services
  48. available, each of which provides a tree of files.
  49. A name space is built by
  50. .I binding
  51. services (or subtrees of services) to names in the name-space-so-far.
  52. Typically, a user's home file server is bound to the root of the name space,
  53. and other services are bound to conventionally named subdirectories.
  54. For example, there is a service resident in the operating system for accessing
  55. hardware devices and that is bound to
  56. .B /dev
  57. by convention.
  58. Kernel services have names (outside the name space) that are a
  59. .L #
  60. sign followed by a single letter;
  61. for example,
  62. .B #c
  63. is conventionally bound to
  64. .BR /dev .
  65. .PP
  66. Plan 9 has
  67. .IR "union directories" :
  68. directories made of several directories all bound to the
  69. same name.
  70. The directories making up a union directory are ordered in a list.
  71. When the bindings are made
  72. (see
  73. .IR bind (1)),
  74. flags specify whether a newly bound member goes at the head or the tail of the list
  75. or completely replaces the list.
  76. To look up a name in a union directory, each member directory is searched
  77. in list order until the name is found.
  78. A bind
  79. flag specifies whether file creation is allowed in a member directory:
  80. a file created in the union directory goes in
  81. the first member directory in list order that allows creation, if any.
  82. .PP
  83. The glue that holds Plan 9 together is a network protocol called
  84. .IR 9P ,
  85. described in section 5 of this manual.
  86. All Plan 9 servers read and respond to 9P requests to navigate through
  87. a file tree and to perform operations such as reading and writing
  88. files within the tree.
  89. .SS Booting
  90. When a terminal is powered on or reset,
  91. it must be told the name of a file server to boot from,
  92. the operating system kernel to boot,
  93. and a user name and password.
  94. How this dialog proceeds is environment- and machine-dependent.
  95. Once it is complete,
  96. the terminal loads a Plan 9 kernel,
  97. which sets some environment variables (see
  98. .IR env (3))
  99. and builds an initial name space.
  100. See
  101. .IR namespace (4),
  102. .IR boot (8),
  103. and
  104. .IR init (8)
  105. for details, but some important aspects of the initial name space are:
  106. .IP \(bu 3
  107. The environment variable
  108. .B $cputype
  109. is set to the name of the kernel's CPU's architecture: one of
  110. .BR mips ,
  111. .BR sparc ,
  112. .B power
  113. (Power PC),
  114. .BR 386
  115. (386, 486, Pentium, ...)
  116. etc.
  117. The environment variable
  118. .B $objtype
  119. is initially the same as
  120. .BR $cputype .
  121. .IP \(bu
  122. The environment variable
  123. .B $terminal
  124. is set to a description of the machine running the kernel,
  125. such as
  126. .B generic
  127. .BR pc .
  128. Sometimes the middle word of
  129. .B $terminal
  130. encodes the file from which the kernel is booted;
  131. e.g.,
  132. .B alpha
  133. .B apc
  134. .B axp
  135. is bootstrapped from
  136. .BR /alpha/9apc .
  137. .IP \(bu
  138. The environment variable
  139. .B $service
  140. is set to
  141. .BR terminal .
  142. (Other ways of accessing Plan 9 may set
  143. .B $service
  144. to one of
  145. .BR cpu ,
  146. .BR con ,
  147. or
  148. .BR rx .)
  149. .IP \(bu
  150. The environment variable
  151. .B $user
  152. is set to the name of the user who booted the terminal.
  153. The environment variable
  154. .B $home
  155. is set to that user's home directory.
  156. .IP \(bu
  157. .B /$cputype/bin
  158. and
  159. .B /rc/bin
  160. are unioned into
  161. .BR /bin .
  162. .PD
  163. .PP
  164. After booting, the terminal runs the command interpreter,
  165. .IR rc (1),
  166. on
  167. .B /usr/$user/lib/profile
  168. after moving to the user's home directory.
  169. .PP
  170. Here is a typical profile:
  171. .IP
  172. .EX
  173. bind -a $home/bin/rc /bin
  174. bind -a $home/bin/$cputype /bin
  175. bind -c $home/tmp /tmp
  176. font = /lib/font/bit/pelm/euro.9.font
  177. upas/fs
  178. switch($service){
  179. case terminal
  180. plumber
  181. prompt=('term% ' ' ')
  182. exec rio -f $font
  183. case cpu
  184. bind /mnt/term/dev/cons /dev/cons
  185. bind /mnt/term/dev/consctl /dev/consctl
  186. bind -a /mnt/term/mnt/wsys /dev
  187. prompt=('cpu% ' ' ')
  188. news
  189. case con
  190. prompt=('cpu% ' ' ')
  191. news
  192. }
  193. .EE
  194. .PD
  195. .PP
  196. The first three lines replace
  197. .B /tmp
  198. with a
  199. .B tmp
  200. in the user's home directory
  201. and union personal
  202. .B bin
  203. directories with
  204. .BR /bin ,
  205. to be searched after the standard
  206. .B bin
  207. directories.
  208. The next starts the mail file system; see
  209. .IR mail (1).
  210. Then different things happen, depending on the
  211. .B $service
  212. environment variable,
  213. such as running the window system
  214. .IR rio (1)
  215. on a terminal.
  216. .PP
  217. To do heavy work such as compiling, the
  218. .IR cpu (1)
  219. command connects a window to a CPU server;
  220. the same environment variables are set (to different values)
  221. and the same profile is run.
  222. The initial directory is the current directory in the terminal window
  223. where
  224. .I cpu
  225. was typed.
  226. The value of
  227. .B $service
  228. will be
  229. .BR cpu ,
  230. so the second arm of the profile switch is executed.
  231. The root of the terminal's name space is accessible through
  232. .BR /mnt/term ,
  233. so the
  234. .I bind
  235. is a way of making the window system's graphics interface (see
  236. .IR draw (3))
  237. available to programs running on the CPU server.
  238. The
  239. .IR news (1)
  240. command reports current Plan 9 affairs.
  241. .PP
  242. The third possible service type,
  243. .BR con ,
  244. is set when the CPU server is called from a non-Plan-9 machine,
  245. such as through
  246. .I telnet
  247. (see
  248. .IR con (1)).
  249. .SS Using Plan 9
  250. The user commands of Plan 9 are reminiscent of those in Research Unix, version 10.
  251. There are a number of differences, however.
  252. .PP
  253. The standard shell is
  254. .IR rc (1),
  255. not the Bourne shell.
  256. The most noticeable differences appear only when programming and macro processing.
  257. .PP
  258. The character-delete character is backspace, and the line-kill character is
  259. control-U; these cannot be changed.
  260. .PP
  261. DEL is the interrupt character: typing it sends an interrupt to processes running in that window.
  262. See
  263. .IR keyboard (6)
  264. for instructions on typing characters like DEL on the various keyboards.
  265. .PP
  266. If a program dies with something like an address error, it enters a `Broken'
  267. state. It lingers, available for debugging with
  268. .IR db (1)
  269. or
  270. .IR acid (1).
  271. .I Broke
  272. (see
  273. .IR kill (1))
  274. cleans up broken processes.
  275. .PP
  276. The standard editor is one of
  277. .IR acme (1)
  278. or
  279. .IR sam (1).
  280. There is a variant of
  281. .I sam
  282. that permits running the file-manipulating part of
  283. .I sam
  284. on a non-Plan-9 system:
  285. .IP
  286. .EX
  287. sam -r tcp!kremvax
  288. .EE
  289. .PP
  290. For historical reasons,
  291. .I sam
  292. uses a tab stop setting of 8 spaces, while the other editors and window systems use 4 spaces.
  293. These defaults can be overridden by setting the value of the environment variable
  294. .B $tabstop
  295. to the desired number of spaces per tab.
  296. .PP
  297. Machine names may be prefixed by the network name,
  298. here
  299. .BR tcp ;
  300. and
  301. .B net
  302. for the system default.
  303. .PP
  304. Login connections and remote execution on non-Plan-9 machines are usually
  305. done by saying, for example,
  306. .IP
  307. .EX
  308. con kremvax
  309. .EE
  310. .PP
  311. or
  312. .IP
  313. .EX
  314. rx deepthought chess
  315. .EE
  316. .PP
  317. (see
  318. .IR con (1)).
  319. .PP
  320. .I 9fs
  321. connects to file systems of remote systems
  322. (see
  323. .IR srv (4)).
  324. For example,
  325. .IP
  326. .EX
  327. 9fs kremvax
  328. .EE
  329. .PP
  330. sets things up so that the root of
  331. .BR kremvax 's
  332. file tree is visible locally in
  333. .BR /n/kremvax .
  334. .PP
  335. .IR Faces (1)
  336. gives graphical notification of arriving mail.
  337. .PP
  338. The Plan 9 file server has an integrated backup facility.
  339. The command
  340. .IP
  341. .EX
  342. 9fs dump
  343. .EE
  344. .PP
  345. binds to
  346. .B /n/dump
  347. a tree containing the daily backups on the file server.
  348. The dump tree has years as top level file names, and month-day
  349. as next level file names.
  350. For example,
  351. .B /n/dump/2000/0120
  352. is the root of the file system as it appeared at dump time on
  353. January 20, 2000.
  354. If more than one dump is taken on the same day, dumps after
  355. the first have an extra digit.
  356. To recover the version of this file as it was on June 15, 1999,
  357. .IP
  358. .EX
  359. cp /n/dump/1999/0615/sys/man/1/0intro .
  360. .EE
  361. .PP
  362. or use
  363. .IR yesterday (1).
  364. .SH SEE ALSO
  365. This section for general publicly accessible commands.
  366. .br
  367. Section (2) for library functions, including system calls.
  368. .br
  369. Section (3) for kernel devices (accessed via
  370. .IR bind (1)).
  371. .br
  372. Section (4) for file services (accessed via
  373. .IR mount ).
  374. .br
  375. Section (5) for the Plan 9 file protocol.
  376. .br
  377. Section (6) for file formats.
  378. .br
  379. Section (7) for databases and database access programs.
  380. .br
  381. Section (8) for things related to administering Plan 9.
  382. .br
  383. .B /sys/doc
  384. for copies of papers referenced in this manual.
  385. .PP
  386. The back of this volume has a permuted index to aid searches.
  387. .SH DIAGNOSTICS
  388. Upon termination each program returns a string called the
  389. .IR "exit status" .
  390. It was either supplied by a call to
  391. .IR exits (2)
  392. or was written to the command's
  393. .BI /proc/ pid /note
  394. file
  395. (see
  396. .IR proc (3)),
  397. causing an abnormal termination.
  398. The empty string is customary for successful execution;
  399. a non-empty string gives a clue to the failure of the command.