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