liunx之控制對檔案的訪問

2021-10-12 18:39:33 字數 1989 閱讀 8104

前提建立techdocs組,以及名為tech1、tech2和database1

[root@localhost ~]

# groupadd techdocs

[root@localhost ~]

# useradd tech1

[root@localhost ~]

# useradd tech2

[root@localhost ~]

# useradd database1

[root@localhost ~]

# usermod -g techdocs tech1

[root@localhost ~]

# usermod -g techdocs tech2

建立/home/techdocs的目錄

[root@localhost ~]

# mkdir /home/techdocs

將/home/techdocs目錄的組所有權更改techdocs組

[root@localhost ~]

# chown :techdocs /home/techdocs/

[root@localhost ~]

# ll /home/techdocs/

total 0

[root@localhost ~]

# ls -ld /home/techdocs/

drwxr-xr-x. 2 root techdocs 6 dec 23 21:47 /home/techdocs/

驗證techdocs組中的使用者是否能夠在/home/techdocs目錄配置setgid(2),所有者/使用者和組具有讀取/寫入/執行許可權(7),其他使用者則沒有許可權(0)

[root@localhost ~]

# chmod g+s,g+w,o-r,o-w,o-x /home/techdocs

驗證是否正確設定許可權

[root@localhost ~]

# ls -ld /home/techdocs/

drwxrws---. 2 root techdocs 6 dec 23 21:47 /home/techdocs/

確認techdocs組中的使用者能夠在/home/techdocs目錄中建立和編輯檔案。不屬於techdocs組使用者無法在/home/techdocs目錄中建立和編輯檔案。使用者tech1和tech2在techdocs組中。使用者database1不該組中

[root@localhost ~]

# su - tech1

[tech1@localhost ~]$ touch /home/techdocs/tech1.txt

[tech1@localhost ~]$ echo

"this is tech1"

>> /home/techdocs/tech1.txt

[tech1@localhost ~]$ cat /home/techdocs/tech1.txt

this is tech1

[tech1@localhost ~]$

[database1@localhost ~]$ touch /home/techdocs/dasebase.txt

touch: cannot touch

'/home/techdocs/dasebase.txt'

: permission denied

修改全域性登入指令碼。普通使用者應具有乙個mask設定。該設定將阻止其他人檢視或修改新的檔案和目錄

#vim /etc/profile.d/local-umask.sh

if [&uid -gt 199 ] && ["id -gn「=」id un"];then

umask 007

else

umask 022

fi

控制對檔案的訪問

第二單元 控制對檔案的訪問 截圖檢視17日1 31 檔案系統 是os用於明確儲存裝置 如硬碟 或分割槽上的檔案和資料結構 即在儲存裝置上組織檔案的方法。os中負責管理和儲存檔案資訊的軟體機構稱為檔案管理系統,簡稱檔案系統。檔案系統由三部分組成 檔案系統的介面,對物件操作和管理的軟體集合,物件及屬性。...

控制對檔案的訪問

kiosk foundation0 desktop getfacl file file file 檔名稱 owner kiosk 檔案所有人 group kiosk 檔案所有組 user rw 使用者許可權 user kiosk rwx 特殊指派使用者及許可權 group rw 組許可權 mask ...

控制對檔案的訪問

unit2.2 控制對檔案的訪問 1.許可權列表的讀取 kiosk foundation99 desktop getfacl file file file 檔名稱 owner kiosk 檔案所有人 group kiosk 檔案所有組 user rw 使用者許可權 user kiosk rwx 特殊...