0intro 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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
  107. The environment variable
  108. .B $cputype
  109. is set to the name of the kernel's CPU's architecture: one of
  110. .BR alpha ,
  111. .BR mips ,
  112. .BR sparc ,
  113. .B power
  114. (Power PC),
  115. .BR 386
  116. (386, 486, Pentium, ...)
  117. etc.
  118. The environment variable
  119. .B $objtype
  120. is initially the same as
  121. .BR $cputype .
  122. .IP \(bu
  123. The environment variable
  124. .B $terminal
  125. is set to a description of the machine running the kernel,
  126. such as
  127. .BR "generic 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 apc axp
  133. is bootstrapped from
  134. .BR /alpha/bapc .
  135. .IP \(bu
  136. The environment variable
  137. .B $service
  138. is set to
  139. .BR terminal .
  140. (Other ways of accessing Plan 9 may set
  141. .B $service
  142. to one of
  143. .BR cpu ,
  144. .BR con ,
  145. or
  146. .BR rx .)
  147. .IP \(bu
  148. The environment variable
  149. .B $user
  150. is set to the name of the user who booted the terminal.
  151. The environment variable
  152. .B $home
  153. is set to that user's home directory.
  154. .IP \(bu
  155. .B /$cputype/bin
  156. and
  157. .B /rc/bin
  158. are unioned into
  159. .BR /bin .
  160. .PD
  161. .PP
  162. After booting, the terminal runs the command interpreter,
  163. .IR rc (1),
  164. on
  165. .B /usr/$user/lib/profile
  166. after moving to the user's home directory.
  167. .PP
  168. Here is a typical profile:
  169. .IP
  170. .EX
  171. bind -a $home/bin/rc /bin
  172. bind -a $home/bin/$cputype /bin
  173. bind -c $home/tmp /tmp
  174. font = /lib/font/bit/pelm/euro.9.font
  175. upas/fs
  176. switch($service){
  177. case terminal
  178. plumber
  179. prompt=('term% ' ' ')
  180. exec rio -f $font
  181. case cpu
  182. bind /mnt/term/dev/cons /dev/cons
  183. bind /mnt/term/dev/consctl /dev/consctl
  184. bind -a /mnt/term/mnt/wsys /dev
  185. prompt=('cpu% ' ' ')
  186. news
  187. case con
  188. prompt=('cpu% ' ' ')
  189. news
  190. }
  191. .EE
  192. .PD
  193. .PP
  194. The first three lines replace
  195. .B /tmp
  196. with a
  197. .B tmp
  198. in the user's home directory
  199. and union personal
  200. .B bin
  201. directories with
  202. .BR /bin ,
  203. to be searched after the standard
  204. .B bin
  205. directories.
  206. The next starts the mail file system; see
  207. .IR mail (1).
  208. Then different things happen, depending on the
  209. .B $service
  210. environment variable,
  211. such as running the window system
  212. .IR rio (1)
  213. on a terminal.
  214. .PP
  215. To do heavy work such as compiling, the
  216. .IR cpu (1)
  217. command connects a window to a CPU server;
  218. the same environment variables are set (to different values)
  219. and the same profile is run.
  220. The initial directory is the current directory in the terminal window
  221. where
  222. .I cpu
  223. was typed.
  224. The value of
  225. .B $service
  226. will be
  227. .BR cpu ,
  228. so the second arm of the profile switch is executed.
  229. The root of the terminal's name space is accessible through
  230. .BR /mnt/term ,
  231. so the
  232. .I bind
  233. is a way of making the window system's graphics interface (see
  234. .IR draw (3))
  235. available to programs running on the CPU server.
  236. The
  237. .IR news (1)
  238. command reports current Plan 9 affairs.
  239. .PP
  240. The third possible service type,
  241. .BR con ,
  242. is set when the CPU server is called from a non-Plan-9 machine,
  243. such as through
  244. .I telnet
  245. (see
  246. .IR con (1)).
  247. .SS Using Plan 9
  248. The user commands of Plan 9 are reminiscent of those in Research Unix, version 10.
  249. There are a number of differences, however.
  250. .PP
  251. The standard shell is
  252. .IR rc (1),
  253. not the Bourne shell.
  254. The most noticeable differences appear only when programming and macro processing.
  255. .PP
  256. The character-delete character is backspace, and the line-kill character is
  257. control-U; these cannot be changed.
  258. .PP
  259. DEL is the interrupt character: typing it sends an interrupt to processes running in that window.
  260. See
  261. .IR keyboard (6)
  262. for instructions on typing characters like DEL on the various keyboards.
  263. .PP
  264. If a program dies with something like an address error, it enters a `Broken'
  265. state. It lingers, available for debugging with
  266. .IR db (1)
  267. or
  268. .IR acid (1).
  269. .I Broke
  270. (see
  271. .IR kill (1))
  272. cleans up broken processes.
  273. .PP
  274. The standard editor is one of
  275. .IR acme (1)
  276. or
  277. .IR sam (1).
  278. There is a variant of
  279. .I sam
  280. that permits running the file-manipulating part of
  281. .I sam
  282. on a non-Plan-9 system:
  283. .IP
  284. .EX
  285. sam -r tcp!kremvax
  286. .EE
  287. .PP
  288. For historical reasons,
  289. .I sam
  290. uses a tab stop setting of 8 spaces, while the other editors and window systems use 4 spaces.
  291. These defaults can be overridden by setting the value of the environment variable
  292. .B $tabstop
  293. to the desired number of spaces per tab.
  294. .PP
  295. Machine names may be prefixed by the network name,
  296. here
  297. .BR tcp ;
  298. and
  299. .B net
  300. for the system default.
  301. .PP
  302. Login connections and remote execution on non-Plan-9 machines are usually
  303. done by saying, for example,
  304. .IP
  305. .EX
  306. con kremvax
  307. .EE
  308. .PP
  309. or
  310. .IP
  311. .EX
  312. rx deepthought chess
  313. .EE
  314. .PP
  315. (see
  316. .IR con (1)).
  317. .PP
  318. .I 9fs
  319. connects to file systems of remote systems
  320. (see
  321. .IR srv (4)).
  322. For example,
  323. .IP
  324. .EX
  325. 9fs kremvax
  326. .EE
  327. .PP
  328. sets things up so that the root of
  329. .BR kremvax 's
  330. file tree is visible locally in
  331. .BR /n/kremvax .
  332. .PP
  333. .IR Faces (1)
  334. gives graphical notification of arriving mail.
  335. .PP
  336. The Plan 9 file server has an integrated backup facility.
  337. The command
  338. .IP
  339. .EX
  340. 9fs dump
  341. .EE
  342. .PP
  343. binds to
  344. .B /n/dump
  345. a tree containing the daily backups on the file server.
  346. The dump tree has years as top level file names, and month-day
  347. as next level file names.
  348. For example,
  349. .B /n/dump/2000/0120
  350. is the root of the file system as it appeared at dump time on
  351. January 20, 2000.
  352. If more than one dump is taken on the same day, dumps after
  353. the first have an extra digit.
  354. To recover the version of this file as it was on June 15, 1999,
  355. .IP
  356. .EX
  357. cp /n/dump/1999/0615/sys/man/1/0intro .
  358. .EE
  359. .PP
  360. or use
  361. .IR yesterday (1).
  362. .SH SEE ALSO
  363. This section for general publicly accessible commands.
  364. .br
  365. Section (2) for library functions, including system calls.
  366. .br
  367. Section (3) for kernel devices (accessed via
  368. .IR bind (1)).
  369. .br
  370. Section (4) for file services (accessed via
  371. .IR mount ).
  372. .br
  373. Section (5) for the Plan 9 file protocol.
  374. .br
  375. Section (6) for file formats.
  376. .br
  377. Section (7) for databases and database access programs.
  378. .br
  379. Section (8) for things related to administering Plan 9.
  380. .br
  381. .B /sys/doc
  382. for copies of papers referenced in this manual.
  383. .PP
  384. The back of this volume has a permuted index to aid searches.
  385. .SH DIAGNOSTICS
  386. Upon termination each program returns a string called the
  387. .IR "exit status" .
  388. It was either supplied by a call to
  389. .IR exits (2)
  390. or was written to the command's
  391. .BI /proc/ pid /note
  392. file
  393. (see
  394. .IR proc (3)),
  395. causing an abnormal termination.
  396. The empty string is customary for successful execution;
  397. a non-empty string gives a clue to the failure of the command.