高階許可權acl
修改屬主的許可權
setfacl -m u::許可權 a.txt
修改屬組的許可權
setfacl -m g::許可權 a.txt
修改其他人的許可權
setfacl -m o::許可權 a,txt
修改具體某乙個使用者的許可權
setfacl -m u::使用者名稱:許可權a.txt
修改具體某乙個組的許可權
setfacl -m g:組名:許可權 a.txt
繼承:setfacl -m d:u:egon01:rw a.txt
應用場景:
1、其他人對檔案沒有任何許可權,然後單獨設定其他人裡的egon對檔案
有r許可權。egon02對檔案有w許可權
setfacl -b b.txt
setfacl -m o::- b.txt
setfacl -m u:egon01:r b.txt
setfacl -m u:egon02:w b.txt
2、其他人對檔案有rw許可權,然後單獨設定其他人裡的egon01對檔案有r許可權,
egon02對檔案有w許可權
setfacl -b b.txt
setfacl -m o::rw b.txt
setfacl -m u:egon01:r b.txt
setfacl -m u:egon02:w b.txt
實驗:[root@web01 ~]# pwd
/root
[root@web01 ~]# echo 1111 > b.txt
[root@web01 ~]# getfacl b.txt
# file: b.txt
# owner: root
# group: root
user::rw-
group::r--
other::r--
[root@web01 ~]# setfacl -m o::- b.txt
[root@web01 ~]# setfacl -m u:egon01:r b.txt
[root@web01 ~]# setfacl -m u:egon02:w b.txt
[root@web01 ~]# getfacl b.txt
# file: b.txt
# owner: root
# group: root
user::rw-
user:egon01:r--
user:egon02:-w-
group::r--
mask::rw-
other::---
[root@web01 ~]# su - egon01 -c "cat /root/b.txt"
[root@web01 ~]# su - egon01 -c "echo 222 >> /root/b.txt"
-bash: /root/b.txt: 許可權不夠
[root@web01 ~]# su - egon02 -c "cat /root/b.txt"
cat: /root/b.txt: 許可權不夠
[root@web01 ~]# su - egon02 -c "echo 222 >> /root/b.txt"
[root@web01 ~]#
特殊屬性
+i+a
+a讓普通使用者具備管理員許可權
su切換使用者身份:從乙個使用者切換到另乙個身份
儲備知識:
linux中shell分為兩種級別
登入級別shell:/etc/profile ----> /etc/profile.d/*.sh--->~/.bash_profile---->
~/.bashrc -----> /etc/bashrc
①輸入賬號密碼進來
②su - 使用者名稱 (管理員root切換到普通使用者下無需輸入密碼,反之需要)
非登入級別shell:~/.bashrc ----->/etc/bashrc----> /etc/profile.d/*.sh
1、su 使用者名稱
如果想針對所有使用者以及登入與非登入shell設定統一的配置--->/etc/bashrc
[root@web01 ~]# vim /etc/bashrc
[root@web01 ~]# source /etc/bashrc # 當前環境讓該檔案生效
或者重啟也可以生效
/etc/profile------------->登入級別的所有使用者
ps : shell 的使用分兩種
互動式非互動式
sudo提權:不切換使用者,即使用者身份不變,但是可以獲取root的部分許可權
在管理員下修改配置檔案/etc/sudoers來分配許可權
vim /etc/sudoers 高風險
visudo -c 檢查語法
visudo 不需要加檔案路徑
總結:su :
特點:直接切換到root賬號下進行操作,輸入的是root的密碼
優點:簡單粗暴
缺點:root密碼容易洩露,普通使用者獲取了部分管理許可權
sudo:
特點:在普通使用者下進行操作,不需要切換到root賬號下,在執行操作命令
格式為 : sudo 命令,輸入的是普通使用者自己的密碼
優點:root密碼沒有洩露,普通使用者獲取了部分管理許可權
缺點:相對複雜
使用者 主機ip或主機名=**成的使用者身份)管理命令
egon01 all=(all) /usr/sbin/ifconifg
egon01 all=(all) nopasswd:/usr/sbin/ifconifg
egon01 all=(all) nopasswd:命令的別名
egon01 all=(all) all,!/usr/bin/vim /test/b.txt
all代表的是服務端ip位址,與客戶端無關
Linux高階許可權管理
傳統的ugo rwx wx wx 許可權模型,無法解決當多個組需要對乙個檔案執行某些許可權的問題.acl 訪問控制列表access control list一種高階的許可權機制,允許我們對檔案或者資料夾進行高階的設定,acl允許針對不同使用者 不同組隊對乙個目標檔案或資料夾進行許可權設定,不受ugo...
許可權管理 高階許可權
一.高階許可權管理acl 使用setfacl命令可以對每乙個檔案或者目錄設定更精確的檔案許可權,比如 讓某乙個使用者對某一檔案具有某種許可權.這種獨立於u,g,o的rwx許可權之外的具體許可權設定叫acl,它可以對單一使用者,單一檔案或者目錄進行r,w,x的許可權控制.1.getfacl opt a...
linux高階許可權suid sgid sticky
1.分析以下問題 root w hat ll root file1.txt rw r r 1 root root 0 aug 4 16 13 root file1.txt sfj1 w hat cat root file1.txt cat root file1.txt permission deni...