home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / c / cops_104.zip / cops_104 / checkacct / write < prev   
Text File  |  1992-03-10  |  4KB  |  106 lines

  1.  
  2. All information on the computer is stored in files.  A file is just
  3. what it sounds like, a container for data.  A directory is a special
  4. file that contains other files or directories.  You can list which
  5. files are in a directory using the "ls" command. For example, here's
  6. what "ls" says about the directory where I'm located:
  7.  
  8. RFC1147.ps    acct.sec    imp.tech     new.security
  9. orange-book   privacy     pu.environ   ritalin
  10. s.serv        s.serv.tr   style        wwarticle
  11. zap
  12.  
  13. You can use "ls" to find out additional information about files by
  14. using the "-l" option.  For example, if I wanted more information about
  15. the file acct.sec in the list above, I would type Here is what happens
  16. when I do that:
  17.  
  18. -rw-r--r--  1 pat  8058 Aug 19 11:22 acct.sec
  19.  
  20.    - The first field shown as, "-rw-r--r--", is the file
  21.      type and permission bits.  More information about permission codes
  22.      is given below.
  23.  
  24.    - The second field, "1", is the number of links to the
  25.      file.  In this case, the file has only one name.  Other links can
  26.      be made with the "ln" command.
  27.  
  28.    - The third field, "pat", is the file's owner.  The login
  29.      pat owns this file.
  30.  
  31.    - The fourth field, "8058", is the size of the file in
  32.      number of characters.
  33.  
  34.    - The fifth field, "Aug 19 11:22", is the time the file
  35.      was last modified.
  36.  
  37.    - The last field is the name of the file.
  38.  
  39. PERMISSION CODES
  40. ----------------
  41. The first character in the type/permission field is the file type.  If
  42. the file is a directory, the first character will be a "d".  If it is a
  43. regular file, the first character will be "-".
  44.  
  45. The next nine characters are access permission flags.  The leftmost
  46. three are owner permissions, the middle three are group permissions,
  47. and the rightmost three are world permissions.  The letter "r" grants
  48. read permission, the letter "w" grants write permission, and the letter
  49. "x" grants execute permission.
  50.  
  51. In the above example, the permissions for the owner, "pat", are "rw-".
  52. That means the owner "prm" can read and write the file, but not execute
  53. it.  The permissions for the file's group are "r--", as they are for
  54. the world.  If a file has modes "rw-rw----" and is owned by group
  55. other, everyone on the computer can write to the file!  You can see
  56. group ownership on a file by using the "g" option with the "l" option
  57. to "ls".
  58.  
  59. For example, when I type "ls -l" I get the following:
  60.  
  61. -rw-r--r--  1 pat  other  8058 Aug 19 11:22 acct.sec
  62.  
  63. The "other" is the group owner of the file.
  64.  
  65. You can use the "chmod" command to change file permissions.  The
  66. character "+" means add permission and the character "-" means deny
  67. permission.  For example, if I wanted to let people in group "other"
  68. write on my file, I would type Whereas if I want to deny other people
  69. permission to look at this file, I could type and the read permission
  70. on the file would be revoked.
  71.  
  72. There is a shorthand way of representing file modes.  Each permission
  73. category (owner, group, and world) is given a number which represents
  74. the bits set in the permission field. Here is a table that explains
  75. this numbering system:
  76.  
  77.              _________________________________
  78.             |           Owner   Group   World|
  79.              _________________________________
  80.             | Read       400     40       4  |
  81.             | Write      200     20       2  |
  82.             | Execute    100     10       1  |
  83.               None         0      0       0
  84.             |________________________________+
  85.  
  86. To use this table, merely add up the permissions you want.  For
  87. example, a file that is mode 644 has owner read and write permission
  88. (400 + 200), group read permission (40), and world read permission
  89. (4).
  90.  
  91. You can use this shorthand with "chmod" as well.  Just use the number
  92. instead of the symbolic representation.  If you want to change the mode
  93. of your .login from 755 to 644, you can type
  94.  
  95.     /bin/chmod 0644 ~/.login
  96.  
  97. Your home directory should be mode 700, 711, or 755.  You should not
  98. allow others write permission to your directory!  That would give them
  99. permission to create or destroy files at will.
  100.  
  101. Important files should be mode 644 or 600.  Only rarely is it important
  102. to make a file mode 666, which is world- writable.
  103.  
  104. [Excerpted from "Guide to Account Security" -- Purdue Engineering Computer 
  105.  Network (ECN) "No Name Newsletter" September 1991]
  106.