共計 1067 個字符,預計需要花費 3 分鐘才能閱讀完成。
這篇文章主要為大家展示了“Linux 權限管理之目錄權限限制的示例分析”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“Linux 權限管理之目錄權限限制的示例分析”這篇文章吧。
最近,項目對 Linux 文件目錄有要求:業務用戶及其啟動進程能對指定目錄 drwx,其中有一個用戶對該業務用戶的目錄中的一個子目錄能夠 rwx,
但是對該子目錄以上的其他目錄不能進行讀寫操作。其實實現很簡單,假設 root 是業務用戶,test 是受限用戶,/test/t1 是 root 的業務目錄,/test/t1/t2
是 test 用戶能夠訪問并進行操作的受限目錄,那么只需要給 /test 一個 701,給 t1 一個 701,給 /test/t1/t2 一個 700 并將 t2 的屬組及宿主改為 test:test 就能
保證 root 能對 /test 下任何文件及目錄的絕對操作權限又能把 test 用戶限制在 /test/t1/t2 中,test 用戶不能對 /test 或 /test/t1 進行讀寫操作。
示例如下:
[root@oratest /]# ls -l
total 192
…
drwx—–x 3 root root 4096 Apr 26 17:21 test
…
[root@oratest /]#
[root@oratest test]# ls -l
total 4
drwx—–x 3 root root 4096 Apr 26 17:21 t1
[root@oratest test]#
[root@oratest t1]# ls -l
total 4
-rw-r–r– 1 root root 0 Apr 26 17:21 t
drwx—— 2 test test 4096 Apr 27 09:30 t2
[root@oratest t1]#
[test@oratest ~]$ cd /test
[test@oratest test]$ ls
ls: .: Permission denied
[test@oratest test]$ cd t1
[test@oratest t1]$ ls
ls: .: Permission denied
[test@oratest t1]$ cd t2
[test@oratest t2]$ ls
1 b
[test@oratest t2]$ touch a
[test@oratest t2]$ ls
1 a b
[test@oratest t2]$
以上是“Linux 權限管理之目錄權限限制的示例分析”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!