Linux Phần mềm mã nguồn mở (HUST) - C4. Tài khoản NSD và phân quyền truy cập tệp

LI
lienhejb
0 次下载
26
0

资料内容

第 2 页

Nội dung  Khái niệm NSD và nhóm NSD  Quản lý NSD và nhóm NSD  Khái niệm quyền truy cập  Quyền truy cập của file  Quyền truy cập của thư mục  Quản lý quyền truy cập goupee.com fb.com/groups/goupee

第 3 页

Khái niệm người sử dụng  NSD thông thường  Quản trị  Nhóm NSD  Tạo một người sử dụng  Tên, Mật khẩu, home của người sử dụng (/home/tên)  Nhóm (một người sử dụng có thể thuộc một hoặc nhiều nhóm, tuy nhiên cần phải xác định một nhóm chính)  Tất cả các thông tin về người sử dụng được lưu trong file: /etc/passwd goupee.com fb.com/groups/goupee

第 4 页

/etc/passwd  Username:password:UID:GID:Info:Home:Shell  Username: It is used when user logs in. It should be between 1 and 32 characters in length.  Password: An x character indicates that encrypted password is stored in /etc/shadow file.  User ID (UID): Each user must be assigned a user ID (UID). UID 0 (zero) is reserved for root and UIDs 1-99 are reserved for other predefined accounts. Further UID 100- 999 are reserved by system for administrative and system accounts/groups.  Group ID (GID): The primary group ID (stored in /etc/group file)  User ID Info: The comment field. It allow you to add extra information about the users such as user's full name, phone number etc. This field use by finger command.  Home directory: The absolute path to the directory the user will be in when they log in. If this directory does not exists then users directory becomes /  Command/shell: The absolute path of a command or shell (/bin/bash). Typically, this is a shell. Please note that it does not have to be a shell. 4 goupee.com 10/9/2009 @ Ha Quoc Trung 2009fb.com/groups/goupee

第 5 页

/etc/shadow  User:Pwd:Last pwd change :Minimum:Maximum:Warn:Inactive :Expire  User name : It is your login name  Password: It your encrypted password. The password should be minimum 6-8 characters long including special characters/digits  Last password change (lastchanged): Days since Jan 1, 1970 that password was last changed  Minimum: The minimum number of days required between password changes i.e. the number of days left before the user is allowed to change his/her password  Maximum: The maximum number of days the password is valid (after that user is forced to change his/her password)  Warn : The number of days before password is to expire that user is warned that his/her password must be changed  Inactive : The number of days after password expires that account is disabled  Expire : days since Jan 1, 1970 that account is disabled i.e. an absolute date specifying when the login may no longer be used 5 goupee.com 10/9/2009 @ Ha Quoc Trung 2009fb.com/groups/goupee

第 6 页

Nhóm người sử dụng  Mỗi người sử dụng có thể thuộc về một hoặc nhiều nhóm  Một nhóm = tên nhóm + danh sách các thành viên  Khả năng chia sẻ các file giữa những người sử dụng trong cùng một nhóm.  Danh sách các nhóm được lưu trữ trong file: /etc/group  root có khả năng tạo ra các nhóm bổ xung, ngoài các nhóm mà hệ điều hành đã ngầm định goupee.com fb.com/groups/goupee

第 7 页

/etc/group  group_name:Password:Group ID (GID): Group List  group_name: It is the name of group. If you run ls -l command, you will see this name printed in the group field.  Password: Generally password is not used, hence it is empty/blank. It can store encrypted password. This is useful to implement privileged groups. X means passwd is stored in /etc/gshadow  Group ID (GID): Each user must be assigned a group ID. You can see this number in your /etc/passwd file.  Group List: It is a list of user names of users who are members of the group. The user names, must be separated by commas. 7 goupee.com 10/9/2009 @ Ha Quoc Trung 2009fb.com/groups/goupee

第 8 页

/etc/gshadow  Group name — The name of the group. Used by various utility programs as a human-readable identifier for the group.  Encrypted password — The encrypted password for the group. If set, non- members of the group can join the group by typing the password for that group using the newgrp command. If the value of this field is !, then no user is allowed to access the group using the newgrp command. A value of !! is treated the same as a value of ! — however, it also indicates that a password has never been set before. If the value is null, only group members can log into the group.  Group administrators — Group members listed here (in a comma delimited list) can add or remove group members using the gpasswd command.  Group members — Group members listed here (in a comma delimited list) are regular, non-administrative members of the group. 8 goupee.com 10/9/2009 @ Ha Quoc Trung 2009fb.com/groups/goupee

第 9 页

Công cụ  useradd/mod/del  passwd  groupadd/mod/del  gpasswd  sg/newgrp  su  users/groups  id 9 goupee.com 10/9/2009 @ Ha Quoc Trung 2009fb.com/groups/goupee

第 10 页

Các quyền  Mỗi file luôn thuộc về một người sử dụng và một nhóm xác định Người tạo ra file hoặc thư mục sẽ là người sở hữu, nhóm chứa người tạo ra file hoặc thư mục sẽ là nhóm sở hữu đối với file/thư mục.  Sự phân quyền cho phép xác định rõ các quyền mà người sử dụng có đối với một file hoặc một thư mục. goupee.com fb.com/groups/goupee

第 11 页

Quyền truy cập  r : đọc  Cho phép hiển thị nội dung của file hoặc thư mục  w : ghi  Cho phép thay đổi nội dung của file  Cho phép thêm hoặc xóa các file trong một thư mục  x : thực thi  Cho phép thực thi file dưới dạng một chương trình  Cho phép chuyển đến thư mục cần truy cập goupee.com fb.com/groups/goupee

第 12 页

Các nhóm người sử dụng  Có 3 nhóm người sử dụng đối với 1 file/ thư mục:  u (người sở hữu) : người sở hữu duy nhất của file  g (groupe) : những người sử dụng thuộc nhóm chứa file  o (others) : những người sử dụng khác, không phải là người sở hữu file cũng như không thuộc nhóm chứa file.  Mỗi nhóm người sử dụng sẽ có một tập các quyền (r, w, x) xác định. goupee.com fb.com/groups/goupee

第 13 页

Ví dụ $ ls -l ----rw-rw- 1 tuananh user1 16 Feb 10 19:12 test1.txt -rw-rw-rw- 1 tuananh user1 16 Feb 10 19:12 test2.txt drw-r--r-- 2 tuananh user1 512 Feb 10 19:14 vanban $ whoami tuananh $ cat test1.txt cat: test1.txt: Permission denied $ cat test2.txt Un fichier de test $ cp test2.txt vanban cp: vanban: Permission denied goupee.com fb.com/groups/goupee

第 14 页

Các lưu ý  Để có thể thêm các file, cần phải có quyền « w » đối với thư mục  Để có thể xóa, thay đổi nội dung hoặc di chuyển 1 file, người sử dụng cũng cần phải có quyền « w » đối với thư mục  Việc xóa một file còn phụ thuộc vào quyền đối với thư mục chứa file đó  Để bảo mật các dữ liệu, người sở hữu file thậm chí có thể bỏ cả quyền đọc « r » đối với tất cả mọi người sử dụng khác.  Để hạn chế quá trình truy cập vào hệ thống file, người sử dụng có thể bỏ quyền thực thi (x) đối với thư mục gốc goupee.comcủa hệ thống file. fb.com/groups/goupee

第 15 页

Một số quyền đặc biệt đối với các file thực thi  set-uid: -rws --- ---  Chương trình được chạy dưới quyền của người sở hữu  set-gid: - --- rws ---  Chương trình được chạy bởi các người sử dụng thuộc cùng nhóm với người sở hữu  bit sticky  Chương trình chỉ được cấp phát bộ nhớ trong 1 lần goupee.com fb.com/groups/goupee

第 16 页

Ví dụ $ ls -l /etc/passwd -rw-rw---- 1 root root 568 Feb 10 19:12 passwd $ ls -l /bin/passwd -rwsrws--x 1 root root 3634 Feb 10 19:12 passwd  Khi một người sử dụng thông thường gọi lệnh /bin/passwd, xem như người đó được « mượn » quyền root để thay đổi mật khẩu trong file /etc/passwd goupee.com fb.com/groups/goupee

第 17 页

Thay đổi quyền truy cập (1) $chmod <mode> <files> set_uid set-gid sticky user group other rwx --x --x 1 1 0 111 001 001 6 7 1 1 $ chmod 6711 test $ ls -l test -rws--s--x 1 tuananh user1 Mar 10 10:20 test $ chmod 711 test $ ls -l test -rwx--x--x 1 tuananh user1 Mar 10 10:20 test goupee.com fb.com/groups/goupee

第 18 页

Thay đổi quyền truy nhập (2) $chmod <ugoa><+-=><rwsx> <files>  u | g | o | a (all)  Operation  + (thêm 1 hoặc 1 số quyền vào tập các quyền file đã có)  - (bỏ 1 hoặc 1 số quyền khỏi tập các quyền file đã có)  = (gán mới 1 hoặc 1 số quyền cho file)  Quyền = r | w | x | s goupee.com fb.com/groups/goupee

第 19 页

Ví dụ $ ls -l test.txt -rw-rw-r-- 1 tuananh user1 150 Mar 19 19:12 test.txt $ chmod o+w test.txt $ ls -l test.txt -rw-rw-rw- 1 tuananh user1 150 Mar 19 19:12 test.txt $ chmod a-rw test.txt $ ls -l test.txt ---------- 1 tuananh user1 150 Mar 19 19:12 test.txt $ cat test.txt cat: test.txt: Permission denied goupee.com fb.com/groups/goupee

第 20 页

Định nghĩa các quyền ngầm định khi tạo ra 1 file  Các quyền ngầm định của 1 file khi tạo ra có thể được xác định bằng lệnh umask $umask 022  Số 0 có nghĩa là quyền của người sử dụng không bị hạn chế (rwx)  Số 2 có nghĩa là quyền ghi (w) bị hạn chế (r-w). $umask 022 goupee.com fb.com/groups/goupee

显示前 20 页。下载资料查看完整内容。

评论 (0)

登录 以加入讨论

暂无评论。快来抢沙发吧!