特殊權限set_uid 該權限只能賦予二進制可執行文件,受權後普通用戶在執行該文件時臨時擁有它的全部者的權限
node
目錄也可添加該權限,但無實際意義centos
[root@24centos7-01 /]# which passwdide
/usr/bin/passwdui
[root@24centos7-01 /]# ls -l /usr/bin/passwdcentos7
-rwsr-xr-x. 1 root root 27832 6月 10 2014 /usr/bin/passwdspa
添加set_uid權限對象
[root@24centos7-01 /]# chmod u+s /usr/bin/ls索引
[root@24centos7-01 /]# ls -l /usr/bin/lsit
-rwsr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/lsclass
受權後普通用戶可使用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
特殊權限set_gid 該權限只能賦予二進制可執行文件,受權後普通用戶在執行該文件時臨時擁有它的全部者的所屬組的權限
能夠做用在文件和目錄上,當對像是文件時,和set_uid效果相同,可以使執行該文件的普通用戶臨時擁有所屬主的權限;對象是目錄時,當建立子文件或目錄時,所建立的文件或目錄的所屬組和該目錄保持一致
添加set_gid權限
[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
特殊權限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
硬連接 不支持目錄,僅支持文件
硬鏈接指經過索引節點來進行鏈接。在Linux的文件系統中,保存在磁盤分區中的文件無論是什麼類型都給它分配一個編號,稱爲索引節點號(Inode Index)。在Linux中,多個文件名指向同一索引節點是存在的。通常這種鏈接就是硬鏈接。硬鏈接的做用是容許一個文件擁有多個有效路徑名,這樣用戶就能夠創建硬鏈接到重要文件,以防止「誤刪」的功能。其緣由如上所述,由於對應該目錄的索引節點有一個以上的鏈接。只刪除一個鏈接並不影響索引節點自己和其它的鏈接,只有當最後一個鏈接被刪除後,文件的數據塊及目錄的鏈接纔會被釋放。也就是說,文件真正刪除的條件是與之相關的全部硬鏈接文件均被刪除
[root@24centos7-01 /]# ln/boot/config-3.10.0-514.el7.x86_64 /tmp/config
ln: 沒法建立硬連接"/tmp/config" =>"/boot/config-3.10.0-514.el7.x86_64": 無效的跨設備鏈接
[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": 不容許將硬連接指向目錄