SUID SGID的简单用法

 

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} @font-face {font-family:Verdana; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-1593833729 1073750107 16 0 415 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 680460288 22 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1791825559; mso-list-type:hybrid; mso-list-template-ids:-2146949730 353005564 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-text:%1; mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

SUID SGID 简单用法

linux 中,有这样一种情况,如果你仔细观察的话,你会发现当你辅以用户其他组以写权限是,现在的每个人都会随便来删除你的修改删除你所建立的文件。为了解决这个问题, linux 下特别引用了占位符来限定权限 SUID SGID Sticky ,这里的 SUID SGID Sticky linux rwx 权限很类似也是 4 2 1 ,下面介绍下这几个权限的简单用法

1           suid sgid 都是对执行权限来说的。


sgid:
如果对一个文件夹设置了 sgid, 任何用户在文件夹下面建立的文件,其所属组都和主文件夹一样。

suid:
如果对一个文件设置了 suid ,那么所有用户都会共享文件所有者的执行权限


sticky:
这个文件的意思是如果一个用户建了一个文件,那么只有这个用户可以删除,其他人不能删除,即使其他用户对这个文件有写权限。

2 ,理解了这几个权限的意思后,我们就可以来具体的更深入的理解者几个命令权限的意思了,下面举个实例来介绍这几个命令

              #useradd   apple                                                    新建的用户 apple

              #useradd   orange   -G   apple                            新建用户   orange

              #mkdir   /share                                                     新建文件夹 /share

              #chown  :apple     /share                                         改变文件的属组为 apple

              #chmod  g+w       /share                                         增加文件同组属性可读

              #su   -   apple

$touch    /share/apple1

$ll –d  apple                                                        切换到 apple 用户,新建文件 apple1 这里注意看会发现 apple1 文件的属主和数组都为自己

$su   -   orange..... 同理操作 orange 用户,会发现情况一样,这里不再列出命令  

……..

$su – root

#chmod g+s  /share     ( 给、 share 文件添加 s 权限,这里如果大家仔细看的话会发现如果所属组原来没有 x 权限的话,这里的 S ,如果原来有 x 权限的话,这里是 s )    

#su – orange

$midir  orange2  /share     ( 这里和 orange1 比较会发现俩个文件袋所属组不一样, orange1 文件的数组为自己,而 orange2 数组为 apple )

$ 这里的 apple 用户不再做,因为其本身的书主和属组都是自己看不出来,这里我们如果相互删除对方的文件的,依然可以删除,这里大家可以试试

$su  -  root

#chmod   o+t  /share

#su -  apple

$touch  apple2  /share

$su  - orange

$touch  orange3   /share

$rm –rf /share/qpple2    ( 这里正常的删除掉,大家可以自己试,这里不能上传相片,不再转图了 )

     $rm  -rf   /share/apple3 ( 这里会提示说不允许 )

     $su  -  apple  ( 这里会出现相同的情况 )

这里还可以这样定义#chmod  4755  /share    ==========u+s

                           #chmod  2755   /share   ==========g+s

                           #chmod  1755  /share     ==========o+t

                           #chmod   6755  /share    ==========u+s ,g+s

和rwx很相似吧!!?呵呵                   

好了到这里了实验大致完了,这里离希望大家可以对这几个命令有一个大致的了解,如歌还有什么不懂的就 man   呵呵

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值