ETH官方钱包

創作內容

0 GP

[Linux][CentOS 5.5] 7. ACL 權限設定

作者:game2002│2011-02-24 21:44:15│巴幣:0│人氣:665
7. 特殊權限與 POSIX ACL 權限設定

題目:

  1. Create a new directory in /depts/ called tech. Change the permissions such that root is the owner and hr is the group.
  2. Use ACLs to give full permission for /depts/tech/ to the web group.
  3. Allow alex read/execute (but not write) permission on the /depts/tech/ directory. Set a default ACL if read/write for alex on that directory.
  4. Create some files in /depts/tech/ as several if the users and verify access. Does alex or joshua have access to files? Does manager?

-----------------------------------------------------------------------------------
  

solution

  • 執行此範例時,需要建立練習的使用者帳號及群組。
  • Create a new directory in /depts/ called tech.
  • Change the permissions such that root is the owner and hr is the group.
[root@station8 ~]# nano /etc/fstab

LABEL=/                 /                       ext3    defaults,acl    1 1 (這邊加入,acl 打開 acl 的設定權限)
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/usr              /usr                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda8         swap                    swap    defaults        0 0
/dev/vg0/lvm            /mnt/lvm                ext3    defaults    0 0

[root@server1 /]# mkdir -p /depts/tech/
[root@server1 /]# chown root:hr /depts/tech/
[root@server1 /]# chmod 2770 /depts/tech/
(請思考為何要加上SGID的權限?否則這一行 chmod 2770 看起來其中的 2 好像是非必須的)
Use ACLs to give full permission for /depts/tech/ to the web group.
[root@server1 /]# setfacl -m g:web:rwx /depts/tech/

[root@server1 /]# getfacl /depts/tech/
getfacl: Removing leading '/' from absolute path names
# file: depts/tech
# owner: root
# group: hr
user::rwx
group::rwx
group:web:rwx
mask::rwx
other::---
  • Allow alex read/execute (but not write) permission on the /depts/tech/ directory.
  • Set a default ACL if read/write for alex on that directory.
[root@server1 /]# setfacl -m u:alex:rx /depts/tech/
[root@server1 /]# getfacl /depts/tech/
getfacl: Removing leading '/' from absolute path names
# file: depts/tech
# owner: root
# group: hr
user::rwx
user:alex:r-x
group::rwx
group:web:rwx
mask::rwx
other::---
[root@server1 /]# setfacl -m d:u:alex:rw /depts/tech/
[root@server1 /]# getfacl /depts/tech/
getfacl: Removing leading '/' from absolute path names
# file: depts/tech
# owner: root
# group: hr
user::rwx
user:alex:r-x
group::rwx
group:web:rwx
mask::rwx
other::---
default:user::rwx
default:user:alex:rw-
default:group::rwx
default:mask::rwx
default:other::---
  • Create some files in /depts/tech/ as several if the users and verify access.
  • Does alex or joshua have access to files? Does manager?
  • 使用 joshua 使用者測試權限
[joshua@server1 ~]$ touch /depts/tech/joshua
touch: cannot touch ‘/depts/tech/joshua’: 拒絕不符權限的操作
[joshua@server1 ~]$ exit
# 切換到 manager 此使用者的第二個群組為 web,hr
[root@server1 /]# su - manager
[manager@server1 ~]$ touch /depts/tech/manager
[manager@server1 ~]$ getfacl /depts/tech/manager
getfacl: Removing leading '/' from absolute path names
# file: depts/tech/manager
# owner: manager
# group: hr
user::rw-
user:alex:rw-
group::rwx                      #effective:rw-
mask::rw-
other::---

# 測試 alex 使用者的權限
[alex@server1 ~]$ touch /depts/tech/manager
[alex@server1 ~]$ touch /depts/tech/alex
touch: cannot touch ‘/depts/tech/alex’: 拒絕不符權限的操作
引用網址:http://www.jamesdambrosio.com/TrackBack.php?sn=1242068
All rights reserved. 版權所有,保留一切權利

相關創作

留言共 0 篇留言

我要留言提醒:您尚未登入,請先登入再留言

喜歡★gameculb2002 可決定是否刪除您的留言,請勿發表違反站規文字。

前一篇:[Linux][Cent... 後一篇:[Linux][Cent...


face基於日前微軟官方表示 Internet Explorer 不再支援新的網路標準,可能無法使用新的應用程式來呈現網站內容,在瀏覽器支援度及網站安全性的雙重考量下,為了讓巴友們有更好的使用體驗,巴哈姆特即將於 2019年9月2日 停止支援 Internet Explorer 瀏覽器的頁面呈現和功能。
屆時建議您使用下述瀏覽器來瀏覽巴哈姆特:
。Google Chrome(推薦)
。Mozilla Firefox
。Microsoft Edge(Windows10以上的作業系統版本才可使用)

face我們了解您不想看到廣告的心情? 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】