日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Set_uid set_gid stick_bit 软链接 硬链接

發(fā)布時間:2025/6/15 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Set_uid set_gid stick_bit 软链接 硬链接 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

特殊權(quán)限set_uid 該權(quán)限只能賦予二進制可執(zhí)行文件,授權(quán)后普通用戶在執(zhí)行該文件時臨時擁有它的所有者的權(quán)限

目錄也可添加該權(quán)限,但無實際意義

[root@24centos7-01 /]# which passwd

/usr/bin/passwd

[root@24centos7-01 /]# ls -l /usr/bin/passwd

-rwsr-xr-x. 1 root root 27832 6月 10 2014 /usr/bin/passwd


添加set_uid權(quán)限

[root@24centos7-01 /]# chmod u+s /usr/bin/ls

[root@24centos7-01 /]# ls -l /usr/bin/ls

-rwsr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls

授權(quán)后普通用戶可以使用ls使用

[root@24centos7-01 ~]# su - vitus

[vitus@24centos7-01 ~]$ ls -l /root

總用量 4

-rw-------. 1 root root 1422 10月 13 05:50 anaconda-ks.cfg

drwxr-xr-x 3 root root 42 10月 20 21:19 showtime

drwxr-xr-x 2 root root 45 10月 20 21:37 test



特殊權(quán)限set_gid 該權(quán)限只能賦予二進制可執(zhí)行文件,授權(quán)后普通用戶在執(zhí)行該文件時臨時擁有它的所有者的所屬組的權(quán)限

可以作用在文件和目錄上,當對像是文件時,和set_uid效果相同,可使執(zhí)行該文件的普通用戶臨時擁有所屬主的權(quán)限;對象是目錄時,當創(chuàng)建子文件或目錄時,所創(chuàng)建的文件或目錄的所屬組和該目錄保持一致


添加set_gid權(quán)限

[root@24centos7-01 /]# chmod g+s /usr/bin/ls

[root@24centos7-01 /]# ls -l /usr/bin/ls

-rwxr-sr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls

添加后普通用戶可使用

[vitus@24centos7-01 ~]$ ls -ld /root/

dr-xr-x---. 5 root root 207 10月 20 22:24 /root/


[root@24centos7-01 tmp]# chown :vitus test

[root@24centos7-01 tmp]# ls -ld test

dr-xr-xr-x 2 root vitus 22 10月 22 21:48 test

[root@24centos7-01 tmp]# chmod g+s test

[root@24centos7-01 tmp]# ls -ld test

dr-xr-sr-x 2 root vitus 22 10月 22 21:50 test

[root@24centos7-01 tmp]# mkdir test/abc

[root@24centos7-01 tmp]# ls -l test

總用量 4

drwxr-sr-x 2 root vitus 6 10月 22 21:51 abc

-rw-r--r-- 1 root root 7 10月 22 21:05 test.txt

[root@24centos7-01 tmp]# touch test/tee.txt

[root@24centos7-01 tmp]# ls -l test

總用量 4

drwxr-sr-x 2 root vitus 6 10月 22 21:51 abc

-rw-r--r-- 1 root vitus 0 10月 22 21:53 tee.txt


[root@24centos7-01 tmp]# chmod g-s test

[root@24centos7-01 tmp]# ls -ld test

dr-xr--r-x 4 root vitus 76 10月 22 21:54 test

[root@24centos7-01 tmp]# ls -l test

總用量 4

drwxr-sr-x 2 root vitus 6 10月 22 21:51 abc

-rw-r--r-- 1 root vitus 0 10月 22 21:53 tee.txt

[root@24centos7-01 tmp]# mkdir test/abc1

[root@24centos7-01 tmp]# touch test/tee1.txt

[root@24centos7-01 tmp]# ls -l test

總用量 4

drwxr-sr-x 2 root vitus 6 10月 22 21:51 abc

drwxr-xr-x 2 root root 6 10月 22 21:57 abc1

-rw-r--r-- 1 root root 0 10月 22 21:57 tee1.txt

-rw-r--r-- 1 root vitus 0 10月 22 21:53 tee.txt


特殊權(quán)限stick_bit 防刪除位

chmod o+t directoryname

[root@24centos7-01 tmp]# chmod o+t test

[root@24centos7-01 tmp]# chmod 777 test

[root@24centos7-01 test]# su - user1

上一次登錄:日 10月 2223:13:17 CST 2689pxs/0 上

[user1@24centos7-01 ~]$ cd /tmp/test

[user1@24centos7-01 test]$ touch vitus.txt

[user1@24centos7-01 test]$ ll

總用量 0

-rw-rw-r-- 1 user1 user1 0 10月 22 23:16 vitus.txt

[user1@24centos7-01 test]$ 登出

[root@24centos7-01 test]# su - vitus

上一次登錄:日 10月 2223:13:49 CST 2689pxs/0 上

[vitus@24centos7-01 ~]$ cd /tmp/test

[vitus@24centos7-01 test]$ ll

總用量 0

-rw-rw-r-- 1 user1 user1 0 10月 22 23:16 vitus.txt

[vitus@24centos7-01 test]$ rm -f vitus.txt

[vitus@24centos7-01 test]$ ll

[vitus@24centos7-01 test]$ ll

總用量 0

?

[user1@24centos7-01 ~]$ ls -ld /tmp/

drwxrwxrwt. 13 root root 4096 10月 22 23:04 /tmp/

[vitus@24centos7-01 tmp]$ touch vitus.txt

[vitus@24centos7-01 tmp]$ ls -l

總用量 12

drwxr-xr-x 2 root root 6 10月 22 18:46 1

-rw-r--r-- 1 root root 0 10月 22 18:45 1.txt

drwxrwxr-x 2 root root 6 10月 22 18:48 2

-rw-rw-r-- 1 root root 0 10月 22 18:46 2.txt

-rw-r--r-- 1 vitus vitus 0 10月 22 23:04 vitus.txt

[vitus@24centos7-01 tmp]$ 登出

[root@24centos7-01 tmp]# su - user1

上一次登錄:日 10月 2222:59:58 CST 2689pxs/0 上

[user1@24centos7-01 ~]$ rm -f /tmp/vitus.txt

rm: 無法刪除"/tmp/vitus.txt": 不允許的操作



軟鏈接 做軟鏈接時建議使用絕對路徑

ln -s 源文件 目標文件

[root@24centos7-01 tmp]# mkdir test

[root@24centos7-01 tmp]# ls -ld test/

drwxr-xr-x 2 root root 6 10月 22 23:25 test/

[root@24centos7-01 tmp]# cd test

[root@24centos7-01 test]# touch vitus

[root@24centos7-01 test]# ll

總用量 0

-rw-r--r-- 1 root root 0 10月 22 23:25 vitus

[root@24centos7-01 test]# ln -s /tmp/test/vitus /tmp/vitus

[root@24centos7-01 test]# cd ..

[root@24centos7-01 tmp]# ll

總用量 0

drwxr-xr-x 2 root root 19 10月 22 23:25 test

lrwxrwxrwx 1 root root 15 10月 22 23:26 vitus -> /tmp/test/vitus

?

[root@24centos7-01 test]# rm -f vitus

[root@24centos7-01 test]# cd ..

[root@24centos7-01 tmp]# ls -l

總用量 0

drwxr-xr-x 2 root root 6 10月 22 23:29 test

lrwxrwxrwx 1 root root 15 10月 22 23:26 vitus -> /tmp/test/vitus

?

硬鏈接 不支持目錄,僅支持文件

硬連接指通過索引節(jié)點來進行連接。在Linux的文件系統(tǒng)中,保存在磁盤分區(qū)中的文件不管是什么類型都給它分配一個編號,稱為索引節(jié)點號(Inode Index)。在Linux中,多個文件名指向同一索引節(jié)點是存在的。一般這種連接就是硬連接。硬連接的作用是允許一個文件擁有多個有效路徑名,這樣用戶就可以建立硬連接到重要文件,以防止誤刪的功能。其原因如上所述,因為對應(yīng)該目錄的索引節(jié)點有一個以上的連接。只刪除一個連接并不影響索引節(jié)點本身和其它的連接,只有當最后一個連接被刪除后,文件的數(shù)據(jù)塊及目錄的連接才會被釋放。也就是說,文件真正刪除的條件是與之相關(guān)的所有硬連接文件均被刪除

[root@24centos7-01 /]# ln/boot/config-3.10.0-514.el7.x86_64 /tmp/config

ln: 無法創(chuàng)建硬鏈接"/tmp/config" =>"/boot/config-3.10.0-514.el7.x86_64": 無效的跨設(shè)備連接

[root@24centos7-01 /]# ln -s/boot/config-3.10.0-514.el7.x86_64 /tmp/config

?

[root@24centos7-01 tmp]# ll

總用量 0

lrwxrwxrwx 1 root root 34 10月 23 20:35 config ->/boot/config-3.10.0-514.el7.x86_64

drwxr-xr-x 2 root root 6 10月 22 23:29 test

[root@24centos7-01 tmp]# ln /tmp/test /tmp/test_link

ln: "/tmp/test": 不允許將硬鏈接指向目錄


轉(zhuǎn)載于:https://blog.51cto.com/vitus/1975819

總結(jié)

以上是生活随笔為你收集整理的Set_uid set_gid stick_bit 软链接 硬链接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。