Linux中的特殊許可權

來源:互聯網
上載者:User

標籤:sgid   suid   sticky   

Linux中除了普通許可權之外,還有三個特殊許可權。

       SUID::以檔案的所屬使用者執行,而非執行檔案的使用者,多用於可執行檔,設定suid後,在許可權位中,所屬使用者的 最後一個許可權為變為s,添加SUID許可權可用“+s”表示。

    例如:passwd

[[email protected] ~]$ which passwd/usr/bin/passwd[[email protected] ~]$ ls -l /usr/bin/passwd -rwsr-xr-x. 1 root root 25980 Feb 22  2012 /usr/bin/passwd[[email protected] ~]$

        SGID:主要針對檔案夾,在設定了SGID的檔案夾中建立任何新檔案都繼承該檔案的所屬組,設定sgid後,在許可權位中,所屬組的最後一個許可權位變為s,添加SGID許可權可用“+s”表示。

例如:

[[email protected] ~]$ mkdir ultraera[[email protected] ~]$ ls -ltotal 4drwxrwxr-x 2 adam adam 4096 Nov 27 21:09 ultraera[[email protected] ~]$ chmod g+s ultraera/[[email protected] ~]$ ls -ltotal 4drwxrwsr-x 2 adam adam 4096 Nov 27 21:09 ultraera[[email protected] ~]$ su Password: [[email protected] adam]# mkdir -p ultraera/test[[email protected] adam]# ls -l ultraera/total 4drwxr-sr-x 2 root adam 4096 Nov 27 21:09 test[[email protected] adam]#

        sticky:針對檔案夾,對目錄擁有寫入權限的使用者,僅可以刪除其所擁有的檔案,無法刪除其他使用者所擁有的檔案,設定了sticky之後,在許可權位,other的最後一個許可權位變為t,添加SGID許可權可用“+t”表示。

例如:

[[email protected] tmp]# mkdir ultraera[[email protected] tmp]# chmod a=rwx,o+t ultraera/[[email protected] tmp]# ls -ld ultraera/drwxrwxrwt 2 root root 4096 Nov 27 21:29 ultraera/[[email protected] tmp]# useradd user1[[email protected] tmp]# useradd user2[[email protected] tmp]# su user1[[email protected] tmp]$ touch ./ultraera/test[[email protected] tmp]$ ls -l ultraera/total 0-rw-rw-r-- 1 user1 user1 0 Nov 27 21:31 test[[email protected] tmp]$ exitexit[[email protected] tmp]# su user2[[email protected] tmp]$ rm -f ./ultraera/test rm: cannot remove `./ultraera/test‘: Operation not permitted[[email protected] tmp]$

        

同樣使用chmod來設定特殊許可權,與普通許可權一樣,特殊許可權也可以用數字表示:

suid : 4

sgid : 2

sticky : 1

chmod  4644 filename                  #設定檔案suid許可權chmod  2755 flodername             #設定檔案夾sgid許可權chmod  1755 flodername             #設定檔案夾sticky許可權


本文出自 “南非部落” 部落格,請務必保留此出處http://ultraera.blog.51cto.com/6640392/1583493

Linux中的特殊許可權

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.