lec2.docx

319 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
319
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

lec2.docx

  1. 1. Lecture 2<br />Why?File security Permissions<br /> Why?<br /> Multiuser environment <br /><ul><li>Authentication ‘for logging’
  2. 2. Authorization ‘Privilege on file’</li></ul>………………………………………………………………………<br />what are Permissions?<br /><ul><li>Read r - Write w - Execute x</li></ul>For a file: <br />File = info { owner + mtime + atime + ctime + perm + size } + date+ inode #<br /><ul><li>r To read file [ cat - more - tail - head – copy ]
  3. 3. w To edit file [vi – gedit – copy edit file without read it]
  4. 4. x To execute an executable file (c file should have x to be
  5. 5. executable) ex : commands ls –l date</li></ul>For a directory: <br />Directory = Sheet of the names of its contents(files or dir)<br /><ul><li>r To list content of directory(files and dir names in
  6. 6. this directory (ls dir need read permission)
  7. 7. w To create or remove 0r rename file or dir from the
  8. 8. directory
  9. 9. x To cd to this directory you need execute
  10. 10. To know info about contents of this dir rather than it’s name ls –l directory need (r+x)</li></ul> Note: <br />ls –ld directory<br />Only requires execute on the parent no permission is required for this directory<br /> Ex: <br />cat /etc/passwd<br /> x x x r<br /> ls /etc<br /> x x r<br /> wc /etc/group<br /> x x x r<br /> ls -l /usr/bin<br /> x x x r+w<br /> cd /var<br /> x x x <br />rm /etc/shadow<br /> x x x+w no permission is required<br />cp /etc/passwd /export/home/iti<br /> x x x r x x x x+w<br /> cp /etc/passwd /export/home/iti/pass<br /> x x x r x x x x+w w <br /> if pass not already exists<br />x w <br /> if pass already exists<br />………………………………………………………………………<br />How to view Permissions?<br />For a file: <br />Type of file:- : regular filed: directoryl : softlinkb,c : device files : socket fileex:/var/tmp/mapping-root162560464185ls –l file<br />File nameLast mtimeSizePrimary Group of ownerOwnerLink count<br />For a directory: <br /> ls -ld directory <br />………………………………………………………………………<br />How Permissions are checked?<br />616585-468630<br />………………………………………………………………………<br />How to change Permission?<br />Default for file and directory:<br />File: rw- r- - r- -<br />Directory: rwx r-x r-x<br />chmod command:<br /><ul><li>Symbols
  11. 11. Octal
  12. 12. Symbols:
  13. 13. u: Owner g: group o: others
  14. 14. r: read w: write x: execute
  15. 15. u=rw,g=r,o=r give owner read/write & g read & others read
  16. 16. u+x,g+x,o+x append execute for all
  17. 17. u-rw remove read & write permission from owner
  18. 18. a+r append execute for all (a) equivalent to u&g&o
  19. 19. Octal:
  20. 20. Owner Owner’s group Others
  21. 21.
  22. 22. R W X R W X R W X Denied: 0
  23. 23. Exist: 1
  24. 24. rw- r- - r- - : 110 100 100 : 644
  25. 25. rwx rwx rwx : 111 111 111 : 777</li></ul>How to change mask?<br /><ul><li>What is mask??
  26. 26. How to view mask??
  27. 27. # umask
  28. 28. 0022 Default
  29. 29. How to change mask??
  30. 30. Symbols:
  31. 31. # umask a=rwx
  32. 32. So any file will be created will have permission rw-rw-rw-
  33. 33. & any directory will be created will have permission rwxrwxrwx
  34. 34. # umask
  35. 35. 0000 full permission
  36. 36. Octal:
  37. 37. # umask 000 000 Complement of required permissions
  38. 38. So any file will be created will have permission rw-rw-rw-
  39. 39. & any directory will be created will have permission rwxrwxrwx
  40. 40. Notes:
  41. 41. Touch for already exist file if mask is changed permission won’t be changed due to the new umask as touch only change here the mtime</li></ul>Vi Editor Powerful editor<br /><ul><li>What is different between text editor and word processor??
  42. 42. Text editor: </li></ul>When we write hello in text editor only hello is saved<br />Windows: notepad + edit<br />Solaris: Vi + gedit<br /><ul><li>Word processor: </li></ul>When we write hello in word processor hello is saved + it’s font + weight….<br />Windows: WordPad + Microsoft office<br />Solaris: Open office + star office<br /><ul><li>Vi modes?? </li></ul>vi filename<br />vi –r filename (recover for crash)<br />vi –R filename (Read only) = = view filename wq!(force)<br /><ul><li>Command mode:
  43. 43. Last line mode: :
  44. 44. Esc: To shift to the command mode
  45. 45. Command:
  46. 46. k
  47. 47. hl
  48. 48.
  49. 49. j
  50. 50. i To turn to editing (inserting) mode
  51. 51. a To turn to editing (appending) mode
  52. 52. A To turn to editing mode and go to the end of the line
  53. 53. I To turn to editing mode and go to the beginning of the line
  54. 54. 0 To go to the beginning of line
  55. 55. $ To go to the end line
  56. 56. G To go to the end of file
  57. 57. H To go to the begin of file
  58. 58. R Replace
  59. 59. x Delete the character on cursor
  60. 60. X Delete the character at the left of the cursor
  61. 61. :w Save file
  62. 62. :wq save and quit equivalent to ZZ
  63. 63. :w filename Save as filename
  64. 64. :q To quit refuse to quit if no save
  65. 65. :q! To force to quit without saving
  66. 66. yy To copy current line you are standing on
  67. 67. dd cut current line you are standing on
  68. 68. p paste below the line you are standing on
  69. 69. P Paste above the line you are standing on
  70. 70. y#w copy # words and then paste them where you want
  71. 71. d#w cut # words and then paste them where you want
  72. 72. O begin to write above line you are standing on
  73. 73. o begin to write below line you are standing on
  74. 74. / text Search for the text n: next occurance N: previous occurance
  75. 75. ~ Switch from lower case to upper case & vice versa for
  76. 76. Highlighted word
  77. 77. u undo “but just once” U undo all changes happen to line
  78. 78. . redo
  79. 79. r replace
  80. 80. :# go to line #
  81. 81. #j go to line # relative to current line
  82. 82. :#d cut line #
  83. 83. dH cut from line you r standing on till beginning of file(up)
  84. 84. d0 cut from where you r standing on till end of line == D
  85. 85. dG cut from line you r standing on till end of file(down)
  86. 86. d$ cut from where you r standing on till begin of line
  87. 87. :#dd 3dd cut line you r standing on and 2 lines below this line
  88. 88. :#y copy line #
  89. 89. yH copy from line you r standing on till beginning of file(up)
  90. 90. y0 copy from where you r standing on till end of line
  91. 91. yG copy from line you r standing on till end of file(down)
  92. 92. y$ copy from where you r standing on till begin of line
  93. 93. :#yy 3yy copy line you r standing on and 2 lines below this line
  94. 94. :set number To numbering the file
  95. 95. :set nonu To turn numbering of file off
  96. 96. :set showmode To show mode {command mode } show nothing
  97. 97. a append mode
  98. 98. i insert mode
  99. 99. R replace mode
  100. 100. :set noshowmode To disable set showmode</li></ul>User Administrator <br /> Create account:<br />useradd –md [home directory] –s [default shell] –g [primary group] –G [Secondary group] –c [comment] [username]<br />Example:<br />useradd -md /export/home/guest -s /bin/bash -g staff -G g1,g2 -c “guest user” guest <br /><ul><li>Once this command is executed an entry will be added to /etc/passwd with user information</li></ul> Modify account:<br />usermod –md [new home dir] [username] Modify user’s home directory<br />usermod –s [new default shell] [username] Modify user’s shell <br />usermod –g [new primary group] [username] Modify user’s primary group<br />usermod –G [new Secondary group] [username] <br /><ul><li>Secondary group will be overwritten not appended</li></ul>usermod –c [new comment] [username]<br />usermod –l [new name] [username]<br />Example:<br /><ul><li>Usermod -l newguest guest
  101. 101. Usermod -s /bin/bash guest</li></ul> Delete account:<br />userdel [username] Delete the user without his home directory deletion<br />userdel -r [username] Delete the user with his home directory<br />Example:<br /><ul><li>userdel guest
  102. 102. userdel -r guest</li></ul> Create group:<br />groupadd [groupname] <br />Example:<br /><ul><li>groupadd guestgroup
  103. 103. Once this command is executed an entry will be added to /etc/group
  104. 104. All groups on the system is saved in the file /etc/group</li></ul> Modify group:<br />groupmod –n [new group name] [old group name]<br />Example:<br /><ul><li>groupmod -n newguestgroup guestgroup</li></ul> Delete group:<br />groupdel [ group name]<br />Example:<br /><ul><li>groupdel guestgroup</li></ul> Note:<br />groups [username] To know all the groups that this user is a member in<br />

×