六、特殊权限

1.stickyid      粘制位

针对目录:如果一个目录的stickyid开启后,那么这个目录的文件只能被文件所有人删除

chmod     1原始权限    dir

chmod     o+t                dir

实验:

mkdir /pub

chmod 777 /pub

su - westos ----> touch /pub/westosfile1

exit

su - yxy --------> touch /pub/westosfile2

rm -fr /pub/westosfile2    #可以删除

rm -fr /pub/westosfile1    #不属于自己的文件也可以删除

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

如何解决此问题:

chmod   1777      dir

chmod     o+t          dir

以上两条命令都可以开启pub目录的t权限

su - westos ----> touch /pub/file1

exit

su - yxy --------> touch /pub/file2

rm -fr /pub/file1 #不属于自己的文件不能删除

rm: cannot remove 'westosfile': Operation not permitted

rm -fr /pub/file2 #可以删除 

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

2.sgid       强制位

针对文件:  只针对与二进制可执行文件

                    当文件上有sgid时任何人执行此文件产成的进程都属于文件的的组

                    当运行二进制可执行文件时都是用文件拥有组身份运行,和执行用户无关

针对目录:目录中新建的文件自动归属到目录的所属组中

chmod   2源文件权限     dir

chmod   g+s                   dir

 实验:(目录)

group               westostest

            mkdir                /mnt/westosdir

            chmod   777    /mnt/westosdir

            chgrp  westostest   /mnt/westosdir

            watch   -n  1   ls -lR     /mnt                                      ##监控  

            root ---> touch   /mnt/westosdir/file                      ##是谁建立的文件组就是谁的

            chmod   g+s     /mnt/westosdir

            root ---> touch   /mnt/westosdir/file1                    ##file1自动复制了/mnt/westosdir目录组的所属组

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

实验:(文件)

                       su - westos

                        /bin/watch -n 1 date

                        ps ax -o user,group,comm | grep watch

                        westos     westos      watch

                 用root用户身份

                         chmod g+s /bin/watch

                         su - westos

                         /bin/watch -n 1 date

                         ps ax -o user,group,comm | grep watch

                         westos        root       watch                                ##与执行watch的westos用户无关,还是文件拥有组root

#只针对二进制的可执行文件(c程序)

#当运行二进制可执行文件时都是用文件拥有组身份运行,和执行用户无关

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

3.suid        冒险位

1.只针对二进制的可执行文件(c程序)

2.当运行二进制可执行文件时都是用文件拥有者身份运行,和执行用户无关
chmod   4原属性   file

chmod    u+s    file

 

实验:

                su - westos

                /bin/watch -n 1 date

                ps ax -o user,group,comm | grep watch

                westos   westos   watch

         用root用户身份

                chmod u+s /bin/watch

                su - westos

                /bin/watch -n 1 date

                ps ax -o user,group,comm | grep watch

                root         westos     watch

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

Linux系统中的文件权限管理(2)---特殊权限(sticky 粘制位、sgid 强制位、suid 冒险位)

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2021-10-03
  • 2021-11-09
  • 2021-11-25
猜你喜欢
  • 2021-10-07
  • 2022-12-23
  • 2021-11-30
  • 2021-11-21
  • 2021-05-02
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案