home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / Hack / MISC / MODE-010.ZIP / MODE-010.TXT
Encoding:
Text File  |  1991-05-27  |  20.9 KB  |  500 lines

  1.  
  2.  
  3. *********************************************************
  4. *                                                       *
  5. *                                                       *
  6. *           Unix and its file controllers               *
  7. *                                                       *
  8. *           Another Modernz Presentation                *
  9. *                                                       *
  10. *                        by                             *
  11. *                  Digital-demon                        *
  12. *                                                       *
  13. *            (C)opyright April 2, 1991                  *
  14. *                                                       *
  15. *********************************************************
  16.  
  17.  
  18.  
  19. The Modernz can be contacted at:
  20.  
  21. MATRIX BBS - Sysops: Wintermute & Digital-demon
  22.              (908) 905-6691
  23.  
  24. The Villa Straylight - Sysop: Tal Meta
  25.              (908) 830-7960
  26.  
  27. The Church of Rodney - Sysop: Tal Meta
  28.              (908) 830-7786
  29.  
  30. *********************************************************             
  31.  
  32.  
  33.  
  34. UNIX SYSTEMS
  35.  
  36. Among the multitude of operating systems one is the most commonly used, and
  37. that is UNIX.  UNIX in its varied array of look alike and modifications such
  38. as zenix and other 'nix variations.  These systems have one feature that makes
  39. them stand together and that is the multiuser/multitasking environment. However
  40. I wish to show the files and what commands are used to manipulate them.
  41.  
  42. First you must know that the multi-tasking and multi-user environment , which 
  43. means that it can handle more than one action or user concurrently, is done by
  44. the operating system.  The operating system utilizes a time-sharing routine, by
  45. maintaining the list or queue (which you can understand by reading book on data
  46. structures) of tasks to be done, and shares the time among the jobs waiting to
  47. be processed.  The time frame of processing given to each task is so small the
  48. user believe the system to be processing the jobs simultaneously.
  49.  
  50. Each time a user logs into the system they are associated with their own
  51. particular directory, their 'home' directory. This is not the root of other
  52. operating systems.  Each users has their own 'home' directory which is where
  53. the pointer for the working directory originates instead of the root of most
  54. other operating systems.  UNIX follows the hierarchical directory system as do
  55. most other operating systems.  It also can only manipulate data within the
  56. primary storage, the memory, and automatically handles the movement between the
  57. secondary, disk, and the primary storage system.
  58.  
  59. Within the hierarchical directory structure the operating system keeps track of
  60. the file owner, the last modification date and time, the location of each file,
  61. and the size in bytes (or characters) of data within the file.  They are kept
  62. in a format like this:
  63.  
  64.  /-defines if a directory or not (a - in place of a letter
  65. |  means a no, s means special file)
  66. |
  67. |/-these three characters define the file owner modes 
  68. || the (r-read, w-write, x- execute)
  69. ||
  70. ||  /-these three characters define the users in the same
  71. ||  | group as the owner
  72. ||  |
  73. ||  |  /-these three characters define the other users of
  74. ||  |  | the system
  75. ||  |  |
  76. ||  |  |   /-total # of blocks (1024 bytes)
  77. ||  |  |   |  /-owner name (account name)
  78. ||  |  |   |  |     /-group owner name 
  79. ||  |  |   |  |     |     /-how many characters
  80. ||  |  |   |  |     |     |        
  81. ||  |  |   |  |     |     |         /-last modification time   
  82. ||  |  |   |  |     |     |         |   
  83. ||  |  |   |  |     |     |         |         /-file name
  84. ||  |  |   |  |     |     |         |         |
  85. ||  |  |   |  |     |     |         |         |
  86. drwxr-xr-x 3 neal DP3725  80  March 10 22:12 UNIX 
  87.  
  88.  
  89. The top of the hierarchical structure is called the root.  The root directory
  90. and all associated subdirectories are called a file system.  A hierarchical
  91. system may appear as following:
  92.  
  93.             root
  94.              |  
  95.              | 
  96.   --------------------
  97.   |                  |
  98.  Jim               demon  <-these accounts are user's home
  99.                      |
  100.                 ----------
  101.                |         | 
  102.               docs      homework
  103.                |           |
  104.            ------        ------------
  105.            |    |        |          |
  106.          txt   opsys   calculus    assembly
  107.  
  108.  
  109. Subdirectories within a path are separated by the backslash (/) character.
  110. This character also within the path will define how far from the root the
  111. operating system must travel.  Within the hierarchical structure and the
  112. notation conventions  a single period (.) defines the current working directory,
  113. and two periods (..) define the root.  Note that within the UNIX operating
  114. system the root directory may have a name.  You access files within another
  115. directory by specifying the whole path name, such as the file UNIX within the 
  116. opsys directory is called by the path /demon/docs/opsys/UNIX, remember that
  117. within UNIX capitals and lowercase are recognized as different.  You may have 
  118. files named: UNIX, UNiX,UNIx, etc, within the same directory and have them all
  119. recognized as seperate entities.
  120.  
  121. UNIX is an interesting operating system as the standard comes with three text 
  122. editors, and their are a vast number of other text editors that are nonstandard 
  123. formats but also quite common within system.  Unfortunately because there are 
  124. so many different version of UNIX and its editors and other commands, many of 
  125. those text editors have security risks within them, holes in the permissions, 
  126. and other supposedly security measures, this is cause by the lack of full
  127. understanding of everything within the UNIX system by any one author/programmer
  128. (Midnite Raider 5.)
  129.  
  130. The editor that seems the easiest to use, among programmers from other operating
  131. system is the ed file editor.  It is used in the format ed filename.  It is
  132. similar to most other operating systems, file editors, quite similar in fact 
  133. to DOS's edlin command.
  134.  
  135. $ed names
  136.  
  137. Commands with ed     Description of action
  138. P                    Display the prompt (which within the ed
  139.                      Command appears as an asterisk (*)
  140. *1n                  Print line 1  (note the * is the
  141.                      prompt). 
  142. *1,3n                Print lines 1 through 3.
  143. ?                    Produced when a command is in error,
  144.                      such as 2,8n when there are only 7
  145.                      lines.
  146. *h                   Prints out explanation of errors, should
  147.                      be used after receiving an ? to find
  148.                      out what the error is.
  149. *H                   Automatically prints out all error
  150.                      messages after this is used. It is
  151.                      suggested that this is used right after
  152.                      the P command is given.
  153. *1d                  Delete line 1
  154. *1a                  Append after line 1
  155.  
  156. .                    used in conjunction with the append to
  157.                      tell the operating system when the
  158.                      append is to be terminated.
  159.  
  160. *1,$n                Display entire file.
  161.  
  162. *3,$d                Delete line 3 through the end of file.
  163.  
  164. *$a                  Append at the end of the file.
  165.  
  166. */test               Finds line containing the string "test"
  167.                      Repeating the string will find the next
  168.                      line that contains the string "test" if
  169.                      it exists.
  170.  
  171. *.,$n                Lists from the current line to the end.
  172.  
  173. *s/brick/tear        Changes the string "brick" to "tear" in
  174.                      the example. Only the first term found
  175.                      if more than one on the same line.
  176.  
  177. *s/,/;/g             Would change all the "," to ";" on the
  178.                      current line.
  179.  
  180. *1,$s/,/;/g          Would globally change.  Which means it
  181.                      would search through and on every line
  182.                      change all the "," to ";"
  183.  
  184. *q                   Quit.  Finish editing, however it will
  185.                      not save the file.
  186.  
  187.  
  188. *w                   Write changes to the file defined upon
  189.                      entering.  It save the data/text.
  190.  
  191. *w demon              Writes the changes to the file demon.
  192.  
  193. Line specifiers
  194. .                    current line
  195.  
  196. $                    last line of buffer
  197.  
  198. n                    nth line where n is an integer
  199.  
  200. +n                   n lines from current(or + :1 line,++:2)  
  201.  
  202. -n                   n lines back (- : 1 back, -- :2)
  203.  
  204.  
  205. More powerful than the ed command is the Vi text editor.  The "vee-eye" screen
  206. editor allows the file itself to appear on the screen and to allow the user to
  207. freely move about it.  However because of this reason inexperience users fine
  208. this to be too much of a shock to comprehend.  The editing itself is shown on 
  209. the screen, as the operating system copies the existing file to the buffer, and
  210. the vi makes the terminal screen a "window" showing a screens worth of the file
  211. from the buffer.
  212.  
  213. vi [option(s)] [file(s)]
  214.  
  215. options           Descriptions
  216. -rfile            Attempts to recover file after the editor
  217.                   or system crashes. This will not work if
  218.                   the buffer is overwritten.
  219.  
  220. -l                Sets the LISP mode
  221.  
  222. -wn               Sets the window, screen size, to n number
  223.                   of lines.
  224.  
  225. -R                Sets the editor to read-only mode.  This
  226.                   means the user can move around the text
  227.                   but editing commands are disabled.
  228.  
  229. +command          Use of editor command before the regular
  230.                   editing process.
  231.  
  232.  
  233. Commands within the vi       description
  234. a                            Append to file after the
  235.                              cursor. (Hit the escape key
  236.                              after all appending commands
  237.                              are done.)
  238.  
  239. A                            Append to the file at the end
  240.                              of the current line.
  241.  
  242. I                            Insert to file at the beginning
  243.                              of the line.
  244. i                            Insert to file before the
  245.                              cursor.
  246.  
  247. o                            Open/add a new line below the
  248.                              current line the cursor
  249.                              inhabits.
  250.  
  251. O                            Open/add a new line above the
  252.                              cursor.
  253.  
  254. R                            Replace or over-type text.
  255.  
  256. s                            Substitutes for character under
  257.                              cursor.
  258.  
  259. S                            Substitutes for whole current
  260.                              line.
  261.  
  262. c                            Changes the indicated text.
  263.  
  264. C                            Replace to the end of current
  265.                              line.
  266.  
  267. d                            Deletes the indicated text.
  268.  
  269. D                            Deletes to the end of the line.
  270.  
  271.  
  272. VI editor commands          Description or meaning
  273. dd                           Deletes current line
  274.  
  275. u                            Undo last delete.
  276.  
  277. x                            Deletes under cursor.
  278.  
  279. X                            Deletes in front of cursor.
  280.  
  281. y                            Make a copy "yanks" the
  282.                              indicated text.
  283.  
  284. Y                            Yanks current line.
  285.  
  286. -----------------------------------------------------------
  287.  
  288. k                            Move the cursor up one line.
  289.  
  290. n                            Move the cursor to the left.
  291.  
  292. l                            Move the cursor to the right.
  293.  
  294. j                            Move the cursor down one line.
  295. 2k                           Move cursor up two lines.
  296.  
  297. kk                           Move the cursor up two lines.
  298.  
  299. <digit><j,k,l,or n>          Moves the cursor the specified
  300.                              direction by the number of
  301.                              spaces equal to digit.
  302.  
  303. -----------------------------------------------------------
  304.  
  305. ZZ                           Save to file and quit.
  306.  
  307. ^D                           <control-d> down 1/2 screen
  308.  
  309. ^U                           <control-u> up 1/2 screen
  310.  
  311. /word <carriage return>      String search for "word."
  312.  
  313. ?word <carriage return>      String search for last "word."
  314.  
  315. w                            Go to next word.
  316.  
  317. e                            Go to end of line.
  318.  
  319. b                            Go to previous word
  320.  
  321. dw                           Delete one word
  322.  
  323. d$                           Delete to end of line.
  324.  
  325. cw                           Change word
  326.  
  327. -----------------------------------------------------------
  328.  
  329. :q                           Quit and don't save any changes
  330.  
  331. :w                           Write changes but do not quit.
  332.  
  333. :q!                          Discard changes to file.
  334.  
  335. :1 <carriage return>         Jump to line 1
  336.  
  337. :s/a/is/<carriage return>    Change "a" to "is"
  338.  
  339. ;$ <carriage return>         Go to last line
  340.  
  341. :set number<carriage return> Turn on line numbering.
  342.  
  343.  
  344. Once files have been created with either of those two methods there are many
  345. commands the operating system allows you to use to view and maneuver the files
  346. within the system.
  347.  
  348. To list you files in your current directory, which you would probably like to
  349. do after completing you creation, or your modification of an existing file, you
  350. would probably like to see the file's size.  So you would issue the ls command,
  351. which at the default ($) prompt would look like this : $ ls And it would display
  352. all the file names in the current directory, or if a: $ ls /pathname  is issued
  353. then the dirctory of files within that path are displayed.  A $ ls -l in either
  354. of the formats will diplay all the file parameters within the directory as
  355. explained previously in detail. 
  356.  
  357. Now maybe after listing your files in your currently directory, and assuming you
  358. are all new to this and have only you working directory, which is also your home
  359. directory.  You will want to issue a mkdir command, make directory, which should
  360. include the full path name. In this case you will make a directory called TXT
  361. and a directory called OPSYS.  $ mkdir ./TXT  in that case I created the
  362. directory TXT one down from the current.
  363.  
  364. Now assuming I have created those two subdirectories below my current, which is
  365. the "home" directory in this case.  And I have a bunch of files within the home
  366. direcotry which I would like to move to the directory.  I would issue the $ cp
  367. oldfilename newfilename  The cp is the copy file command.  And if I wish to
  368. move a file to another directory I just define the newfilename with its full
  369. path.  Copying for one directory to another direcotry, neither within the
  370. current just means both files must be defined with the full pathname.
  371.  
  372. However A lazy user can get around using the full pathname in the first filename
  373. as long as prior to the command they had issued the CDPATH command with the
  374. path to be used within.  This command which can be set up like such:  
  375. $ CDPATH=.:..:$HOME  in this case a cd command or a copy command will search 
  376. the list of directories in turn until the desired subdirectory is found or the
  377. list exhausted.  Within the list of this one is (.) for the current directory,
  378. (..) for the parent or root directory, and $HOME for the home directory.  Each
  379. directory or subdirectory is separated by the (:) .
  380.  
  381. Now you come upon some files you don't remember what they are because you named
  382. them funny.  First you would probably issue a concatinate command.  Sure that 
  383. sounds like a joining command and it is if used in that format.  By typing: $ 
  384. cat filename You can display the contents of filename on the screen in normal 
  385. format.  If you wish to see commands within a file that are "unprintable" the 
  386. command $ cat -v filename will display most "unprintable" characters.  They will
  387. appear with a caret before them.  An example is if a control-d is used within
  388. the file, a ^d will appear.  If you issue the command as $ cat filename1
  389. filename2 one file will be listed right after the other.  This is useful when 
  390. in the process of printing a larger number of files, just uses the pipe to the
  391. printer, or if a $ cat filename1 filename2 > filename3 is issued then the two 
  392. files are listed in sequence and saved in file 3.  However if file 3 is 
  393. the name for either of the previous files the cat command wipes the file clean
  394. before anything is saved into it.
  395.  
  396. Now that you have figured out what the strangely named program is, maybe it
  397. would be better to rename the file to something you can remember.  With a single
  398. use of $ mv <old name> <new name>   you have solved you dilema. Or if someone 
  399. else is useing the same account and you don't wish to confuse that user, you 
  400. may use the $ ln <old name> <name> command to link or assign an additional name
  401. which can be used to define the file.  Thereby creating an alias for you pesky
  402. file.  Or if you find that after listing the file you can not figure out a use
  403. for the file and wish to remove it, issue the $ rm command, rm can be followed
  404. by as many names as you wish or you could add the special characters to perform
  405. the job if names are similar.
  406.  
  407. Now suppose you want other people to use this file.  Or you have a file copied
  408. from another user.  You will probably want to or need to redefine the 
  409. permissions.  There are quite a few commands regarding the permissions.  First
  410. before you get the new file from a friend or transfer a file to them, you should
  411. issue the change owner command, which can only be done by the owner or the 
  412. system operator. $ chown newowner file(s).  Then if you wish to change the group
  413. name of the file a simple 'chgrp' command is issued in the form $ chgrp
  414. (newgroupname) (file(s)) which tells which group has permission to access the 
  415. file under the group parameters, needless to say it is not a commonly need
  416. command, but worth Knowing just in case.
  417.  
  418. However you are the kind of person that doesn't wish those other people within
  419. the group to fool around and modify your hard work.  But you would like to show
  420. it off so you want the group to see it.  What do you do?  Well how about issuing
  421. the change file mode command.  This command is the end all of file permissions 
  422. alterations.  It can be used in the format of: $ chmod (absolute-mode)  (file(s))
  423. or in the form: $ chmod (symbolic-mode) (file(s)).  In either format this 
  424. command can be used to set the permissions for either a file or a whole
  425. directory.
  426.  
  427.  
  428. Absolute mode            Meaning
  429. 4000                     Set the user ID upon execution.
  430.  
  431. 2000                     Set the group ID upon execution. 
  432.  
  433. 20#0                     If # is 7, 5, 3, or 1, then set the
  434.                          group ID.  If the # is 6, 4, 2, or
  435.                          0, then enable file locking.
  436.  
  437. 1000                     Reserved
  438.  
  439. 0400                     Owner has read permission.
  440.  
  441. 0200                     Owner has write permission.
  442.  
  443. 0100                     Owner has execute (search)
  444.                          permission.
  445.  
  446. 0040                     Group has read permission.
  447.  
  448. 0020                     Group has write permission.
  449.  
  450. 0010                     Group has execute permission.
  451.  
  452. 0004                     Others have read permission.
  453.  
  454. 0002                     Others have write permission.
  455.  
  456. 0001                     Others have execute permission.
  457.  
  458.  
  459. For example if 0644 is given as the absolute value then the following are 
  460. enabled: 0400 (owner has read permission), 0200 (owner has write permission), 
  461. 0040 (group has read permission) and 0004 (others have read permission).
  462.  
  463. Symbolic mode consists of three parameters within the command.  They are the 
  464. "who" the "operator" and the "permission string".
  465.  
  466. Symbolic mode             Meaning
  467.  
  468. Who
  469. u                         User
  470. g                         Group
  471. o                         Others
  472. a                         All which takes the place of
  473.                           defining as ugo, this is the
  474.                           default of the who parameter.
  475.  
  476.  
  477.  
  478. Operator
  479. +                         Add these permissions to what
  480.                           already exists.
  481. -                         Remove these permission from what
  482.                           already exists.
  483. =                         Assigns absolutely the indicated
  484.                           permissions.  Anything mentioned
  485.                           and those things not mentioned are
  486.                           also affected. 
  487.  
  488. Permission string
  489. r                         Read
  490. w                         Write
  491. x                         Execute
  492. s                         Set ID
  493. l                         Manadatory file lock during use.
  494.  
  495. *********************************************************
  496.    <*     This has been a Modernz Presentation         *>
  497.  
  498. MATRIX BBS (908) 905-6691  look for Digital-demon
  499.  
  500.