特殊权限位set_uid set_gid stick_bit 软链接硬链接
特殊權限位set_uid ?set_gid ? stick_bit ?軟鏈接硬鏈接
[root@alex ~]# ls -l /etc/shadow ? ? ? ? ? ?存放密碼文件 ?
----------. 1 root root 760 Oct 21 01:30 /etc/shadow
[root@alex ~]# ls -l /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832 Jun 10??2014 /usr/bin/passwd
[root@alex ~]# chmod u+s /usr/bin/ls ? ? ? ? ? ? ? ? ? 臨時擁有root權限的寫法?
[root@alex ~]# ls -l /usr/bin/ls
-rwsr-xr-x. 1 root root 117656 Nov??6??2016 /usr/bin/ls
如下示例: ??
[root@alex ~]# su - user
Last failed login: Thu Oct 26 22:22:13 CST 2017 from 183.206.173.194 on ssh:notty
There were 315 failed login attempts since the last successful login.
[user@alex ~]$ ls -l /root/ ? ? ? ?可以使用root的權限 ?
total 20
-rw-r--r--. 1 root root????0 Oct 26 09:22 2.txt
drw-r--r--. 2 root root 4096 Oct 25 08:49 3.txt
drwxr-xr-x. 2 root root 4096 Oct 16 14:01 c
drwxr-xr-x. 2 root root 4096 Oct 18 08:46 m
drwxr-xr-x. 2 root root 4096 Oct 24 09:36 p
drwxr-xr-x. 2 root root 4096 Oct 24 09:34 zx
[user@alex ~]$ ls /root/
2.txt??3.txt??c??m??p??zx
[root@alex ~]# chmod u-s /usr/bin/ls ? ?更改原來的配置?
[root@alex ~]# ls -l /usr/bin/ls
-rwxr-xr-x. 1 root root 117656 Nov??6??2016 /usr/bin/ls
[root@alex ~]# chmod u=rws??/usr/bin/ls ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?另外一種寫法 ??
[root@alex ~]# ls -l /usr/bin/ls
-rwSr-xr-x. 1 root root 117656 Nov??6??2016 /usr/bin/ls
變成大S ?因為沒有x權限 大寫的S也不受影響 也能執行
加上x權限就會變成小s ??
[root@alex ~]# chmod u+x /usr/bin/ls ? ??
[root@alex ~]# ls -l /usr/bin/ls
-rwsr-xr-x. 1 root root 117656 Nov??6??2016 /usr/bin/ls
[root@alex ~]# chmod u-s /usr/bin/ls ? ? ? 清楚的權限的寫法 ?
[root@alex ~]# ls -l /usr/bin/ls
-rwxr-xr-x. 1 root root 117656 Nov??6??2016 /usr/bin/ls
set gid ?可以作用在目錄上也可以作用在子文件上,可以讓普通用戶臨時擁有所屬組的權限?
[root@alex ~]# chmod g+s??p
[root@alex ~]# mkdir p/2.txt ? ? ?
[root@alex ~]# ls -l p
total 8
-rw-r--r--. 1 root root????0 Oct 26 22:49 1.txt
drwxr-sr-x. 2 root user 4096 Oct 26 22:51 2.txt
drwxr-xr-x. 2 root root 4096 Oct 26 22:50 nb
當set _gid ? 擁有組的權限 ?在他所在的組下面,創建的目錄和文件用戶所屬組都是以該組名字定義 ??
stick_bit ?防刪除位
防止別人刪除自己的文件?
加上防刪除位
[root@alex ~]# su - user
Last login: Thu Oct 26 22:22:47 CST 2017 on pts/1
[user@alex ~]$ cd /tmp/
[user@alex tmp]$ cd
[user@alex ~]$ mkdir 1
[user@alex ~]$ chmod 777 1
[user@alex ~]$ ls -l
total 4
drwxrwxrwx. 2 user user 4096 Oct 26 23:09 1
[user@alex ~]$ cd 1
[user@alex 1]$ mkdir 2
[user@alex 1]$ touch 1.txt
[user@alex 1]$ ls -l
total 4
-rw-rw-r--. 1 user user????0 Oct 26 23:10 1.txt
drwxrwxr-x. 2 user user 4096 Oct 26 23:10 2
[user@alex 1]$ rm -r 2 ? ? ? ?這里體現可以刪除 就是沒有加防刪除位 ?
[user@alex 1]$ ls -l
total 0
-rw-rw-r--. 1 user user 0 Oct 26 23:10 1.txt
[user@alex ~]$ chmod o+t 1 ? ? ?加上防刪除位的用法?
[user@alex ~]$ ls -l
total 4
drwxrwxrwt. 2 user user 4096 Oct 26 23:10 1
[root@alex ~]# ln -s /tmp/alex/??/root/p ? ? 軟鏈接的寫法 ??
[root@alex ~]# ls -l /root/p
total 8
-rw-r--r--. 1 root root????0 Oct 26 22:49 1.txt
drwxr-sr-x. 2 root user 4096 Oct 26 22:51 2.txt
lrwxrwxrwx. 1 root user???10 Oct 26 23:25 alex -> /tmp/alex/ ? ? ? 做成軟鏈接
drwxr-xr-x. 2 root root 4096 Oct 26 22:50 nb
軟鏈接 ?左邊是你的源文件 ? 右邊才是軟鏈接文件 ? ?
[root@alex ~]# ls -l x ? ? ? 相對路徑還有絕對路徑 ??
total 0
lrwxrwxrwx. 1 root root 2 Oct 26 23:30 nb -> nb
做軟鏈接盡量使用絕對路徑 ?
硬鏈接不支持對目錄做硬鏈接?
硬鏈接相當于備份 ,即使刪除一份 還有一份存在 。
硬鏈接有一個特性不能對目錄做硬鏈接 ? ?
硬鏈接的實質就是通過文件的inode節點進行連接。我們都知道,Linux下每個文件都對應一個inode結點,都有一個單獨的inode編號。而硬鏈接不同,每一個硬鏈接的inode都與源文件相同。假設我對文件A建立了一個硬鏈接文件B,此時B的inode編號與A相同。?
每個文件可以建立一個或多個硬鏈接,這樣可以達到“防誤刪”的功能,當刪除了源文件時,還可以通過硬鏈接文件來訪問文件數據。?
文件可以做硬鏈接 前提不能跨分區 ?
ln ?硬鏈接的寫法 ?
轉載于:https://blog.51cto.com/11335852/1976722
總結
以上是生活随笔為你收集整理的特殊权限位set_uid set_gid stick_bit 软链接硬链接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于HTML5 WebGL实现 json
- 下一篇: 禅道之需求追踪和多角色协作流程