set_uidnode
權限說明:set uid權限針對二進制可執行文件,使文件在執行階段具備文件全部者的權限。好比passwd這個命令就具備該權限。當普通用戶執行passwd命令時,能夠臨時得到root權限,從而能夠更改密碼。
做用 :set uid的做用是保證普通用戶臨時擁有該命令全部者的身份。給一個文件設置成set uid,前提這個文件是一個二進制,可執行的文件。
**用法:**把一個二進制可執行文件的,全部者的權限上 +s 就添加上了set uid權限。
例如把ls命令設置成set uid 。 #chmod u+s /usr/bin/lslinux
實例:root用戶windows
[root@cham2 ~]# passwd root ^C [root@cham2 ~]# ls -l /usr/bin/passwd -rwsr-xr-x. 1 root root 27832 6月 10 2014 /usr/bin/passwd [root@cham2 ~]# set_uid ^C [root@cham2 ~]# passwd ^C [root@cham2 ~]# ls /etc/shadow /etc/shadow [root@cham2 ~]# ls -l !$ ls -l /etc/shadow ---------- 1 root root 689 10月 25 16:11 /etc/shadow [root@cham2 ~]# w 13:28:19 up 1 day, 1:02, 2 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 二12 25:52m 0.21s 0.21s -bash root pts/1 192.168.230.1 12:22 3.00s 0.05s 0.00s w [root@cham2 ~]# who who whoami [root@cham2 ~]# whoami root [root@cham2 ~]# rws ^C [root@cham2 ~]# ls -l /usr/bin/ls -rwxr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls [root@cham2 ~]# chmod u+s /usr/bin/ls [root@cham2 ~]# ls -l /usr/bin/ls -rwsr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls [root@cham2 ~]# chmod u-s /usr/bin/ls [root@cham2 ~]# chmod u=rws /usr/bin/ls [root@cham2 ~]# ls -l /usr/bin/ls -rwSr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls [root@cham2 ~]# chmod u+x /usr/bin/ls [root@cham2 ~]# ls -l /usr/bin/ls -rwsr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls [root@cham2 ~]#
user用戶:chambash
Last login: Thu Oct 26 13:36:57 2017 [root@cham2 ~]# su - cham 上一次登陸:四 10月 26 13:36:00 CST 2017pts/1 上 [cham@cham2 ~]$ ls /root/ 111 11.txt 123 12.txt 1.txt 22.txt 234 2.txt anaconda-ks.cfg.1 [cham@cham2 ~]$ ls -ld /root/ dr-xr-x---. 6 root root 284 10月 25 17:31 /root/ [cham@cham2 ~]$ ls /root/ ls: 沒法打開目錄/root/: 權限不夠
****#chmod u-s /usr/bin/ls //去除set uid權限****ui
set_gid
set gid不只能做用在文件上,還能做用在目錄上。
權限說明: set gid權限能夠做用在文件上(二進制可執行文件),也能夠做用在目錄上。看成用在文件上時,其功能和set,uid同樣,它會使文件在執行階段具備文件所屬組的權限。目錄被設置這個權限後,任何用戶在此目錄下建立的文件都具備和該目錄所屬的組相同的組。
做用:
看成用在 文件 上的時候 ,其做用和set uid是相似的,它可讓執行這個文件的普通用戶臨時擁有所屬組的身份。
看成用在 目錄 上的時候,建立子目錄或子文件的所屬組和該目錄的所屬組是保持一致的。
用法: 把一個二進制可執行文件的,所屬組的權限上 +s 就添加上了set gid權限。spa
用在 文件上的時候 ,其做用和set uid是相似的,它可讓執行這個文件的普通用戶臨時擁有所屬組的身份。指針
把ls命令設置成set gid 。 #chmod g+s /usr/bin/ls
日誌
實例:code
[root@cham2 ~]# ls -l /usr/bin/ls -rwxr-xr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls [root@cham2 ~]# chmod g+s /usr/bin/ls [root@cham2 ~]# ls -l /usr/bin/ls -rwxr-sr-x. 1 root root 117656 11月 6 2016 /usr/bin/ls 所屬組中的x變成了s 切換user cham [cham@cham2 ~]$ ls -ld /root/ dr-xr-x---. 6 root root 284 10月 25 17:31 /root/ [cham@cham2 ~]$ ls /root/ 111 11.txt 123 12.txt 1.txt 22.txt 234 2.txt anaconda-ks.cfg.1 [cham@cham2 ~]$ ls -ld /root/ dr-xr-x---. 6 root root 284 10月 25 17:31 /root/
用在目錄上的時候,建立子目錄或子文件的所屬組和該目錄的所屬組是保持一致的ip
實例:把234目錄添加set gid權限,而後更改所屬組爲user1,而後在234目錄下建立一個文件chamlinux,其chamlinux的所屬組爲user1。 若是沒有添加set gid權限的話,chamlinux的所屬組應該是root
[root@cham2 ~]# chmod g+s 234 給234目錄加上set gid [root@cham2 ~]# ls -ld 234 drwxrwsr-x 2 root root 6 10月 25 16:41 234 所屬組多了個s [root@cham2 ~]# chown :user1 234 把234的所屬組改爲user1 [root@cham2 ~]# ls -ld 234 看一下 drwxrwsr-x 2 root user1 6 10月 25 16:41 234 [root@cham2 ~]# touch 234/chamlinux 新建一個文件 [root@cham2 ~]# ls -l 234 總用量 0 -rw-r--r-- 1 root user1 0 10月 26 14:07 chamlinux [root@cham2 ~]# mkdir 234/ch 234下面新建一個子目錄 [root@cham2 ~]# ls -l 234/ 所屬組都是user1 總用量 0 drwxr-sr-x 2 root user1 6 10月 26 14:08 ch -rw-r--r-- 1 root user1 0 10月 26 14:07 chamlinux [root@cham2 ~]# chmod g-s 234 去掉set gid [root@cham2 ~]# touch 234/chamlinux111 234新建子文件 [root@cham2 ~]# !ls 看一下 ls -l 234/ 總用量 0 drwxr-sr-x 2 root user1 6 10月 26 14:08 ch -rw-r--r-- 1 root user1 0 10月 26 14:07 chamlinux -rw-r--r-- 1 root root 0 10月 26 14:09 chamlinux111 所屬組是root [root@cham2 ~]# mkdir 234/ch1 新建子目錄 [root@cham2 ~]# !ls 看一下 ls -l 234/ 總用量 0 drwxr-sr-x 2 root user1 6 10月 26 14:08 ch drwxr-xr-x 2 root root 6 10月 26 14:09 ch1 所屬組是root -rw-r--r-- 1 root user1 0 10月 26 14:07 chamlinux -rw-r--r-- 1 root root 0 10月 26 14:09 chamlinux111 [root@cham2 ~]# [root@cham2 ~]# [root@cham2 ~]# ls -ld 234 drwxrwxr-x 4 root user1 64 10月 26 14:09 234
stick_bit
能夠理解爲防刪除位。文件是否能夠被某用戶刪除,主要取決於該文件所在的目錄是否對該用戶具備寫權限。若是沒有寫權限,則這個目錄下的全部文件都不能刪除,同時也不能添加新的文件。若是但願用戶可以添加文件但不能刪除該目錄下其餘用戶的文件,則能夠對父目錄增長該權限。設置該權限後,就算用戶對目錄具備寫權限,也不能刪除其餘用戶的文件。
**做用: * 防止別人刪除本身的文件,root用戶除外。
/tmp的權限是rwt,而不是傳統的rwx。這個叫作防刪除位
實例: 在cham用戶下的 /tmp目錄下 touch一個cham文件,並#chmod 777cham的權限設置成777,在cham裏面編輯一些內容。而後切換到user1用戶下,在user1用戶下能查看並修改cham文件,而不能刪除(除cham用戶和root用戶擁有修改刪除的權限,其餘用戶都不能刪除)。
[cham@cham2 ~]$ whoami cham [cham@cham2 ~]$ cd /tmp/ [cham@cham2 tmp]$ ls 2.txt cham2 ks-script-JG2UJk yum.log 3.txt chamlinux systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy [cham@cham2 tmp]$ touch cham [cham@cham2 tmp]$ ls -l 總用量 8 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwx------ 1 root root 0 10月 25 15:24 3.txt -rw-rw-r-- 1 cham cham 0 10月 26 16:20 cham drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [cham@cham2 tmp]$ vi cham [cham@cham2 tmp]$ chmod 777 cham [cham@cham2 tmp]$ ls -l 總用量 12 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwx------ 1 root root 0 10月 25 15:24 3.txt -rwxrwxrwx 1 cham cham 55 10月 26 16:20 cham drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [cham@cham2 tmp]$ ls -l cham -rwxrwxrwx 1 cham cham 55 10月 26 16:20 cham [user1@cham2 tmp]$ cd /tmp/ [user1@cham2 tmp]$ ls 2.txt cham2 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy 3.txt chamlinux yum.log cham ks-script-JG2UJk [user1@cham2 tmp]$ vi cham user1能夠修改 [user1@cham2 tmp]$ rm -f cham 但不能刪除 rm: 沒法刪除"cham": 不容許的操做
實例:
[user1@cham2 tmp]$ mkdir user1 [user1@cham2 tmp]$ chmod 777 user1 [user1@cham2 tmp]$ ls -l 總用量 12 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwx------ 1 root root 0 10月 25 15:24 3.txt -rwxrwxrwx 1 cham cham 60 10月 26 16:22 cham drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy drwxrwxrwx 2 user1 user1 6 10月 26 16:24 user1 -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [user1@cham2 tmp]$ cd uer1 -bash: cd: uer1: 沒有那個文件或目錄 [user1@cham2 tmp]$ cd user1 [user1@cham2 user1]$ ls -l 總用量 0 -rw-rw-r-- 1 cham cham 0 10月 26 16:25 1.txt drwxrwxr-x 2 cham cham 6 10月 26 16:25 456 [cham@cham2 tmp]$ cd user1 [cham@cham2 user1]$ touch 1.txt [cham@cham2 user1]$ mkdir 456 [cham@cham2 user1]$ ls 1.txt 456 [cham@cham2 user1]$ ls -l 總用量 0 -rw-rw-r-- 1 cham cham 0 10月 26 16:25 1.txt drwxrwxr-x 2 cham cham 6 10月 26 16:25 456 [user1@cham2 user1]$ rm -f 1.txt [user1@cham2 user1]$ rm -r 456 rm:是否刪除有寫保護的目錄 "456"?y [user1@cham2 user1]$ ls [user1@cham2 user1]$ ls -l 總用量 0 [user1@cham2 user1]$ pwd /tmp/user1 [cham@cham2 tmp]$ mkdir cham11 [cham@cham2 tmp]$ chmod 777 cham11 [cham@cham2 tmp]$ ls -l 總用量 12 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwx------ 1 root root 0 10月 25 15:24 3.txt -rwxrwxrwx 1 cham cham 1 10月 26 16:48 cham drwxrwxrwx 2 cham cham 6 10月 26 16:58 cham11 drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy drwxrwxrwx 2 user1 user1 6 10月 26 16:27 user1 -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [user1@cham2 tmp]$ cd cham11 [user1@cham2 cham11]$ touch 123 [user1@cham2 cham11]$ mkdir 456 [user1@cham2 cham11]$ ls 123 456 [cham@cham2 tmp]$ cd cham11 [cham@cham2 cham11]$ rm -v 123 rm:是否刪除有寫保護的普通空文件 "123"?y 已刪除"123" [cham@cham2 cham11]$ rm -v 456 rm: 沒法刪除"456": 是一個目錄 [cham@cham2 cham11]$ rm -rv 456 rm:是否刪除有寫保護的目錄 "456"?y 已刪除目錄:"456"
總結: **一個目錄下的文件能不能刪除,不取決於這個目錄下的文件的權限,而是取決於這個文件所在目錄的權限,是否可寫。**因此當一個目錄的others權限是可讀可寫時(目錄默認權限有可執行,由於打開目錄,就至關於執行了該目錄),其餘人就能夠刪除這個目錄下的任何文件,包括root文件。
軟連接
軟連接 作軟連接時建議!儘可能!使用絕對路徑
用命令ls -l查看的第一個屬性爲 l 的文件就是連接文件,它相似於windows下的快捷方式。這種文件在Linux中是很常見的。以下圖
能夠看到這一行的第一個字母是 l ,這個 l 就表明它是一個連接文件 。/bin 至關於Windows下的快捷方式,而usr/bin纔是它真正的目錄。
使用命令 #ls -l /lib64 的時候,能夠看到一些粉綠色的,第一個屬性爲 l 文件都是一些軟連接文件。
軟連接: 也稱爲符號連接,即「symbolic links/soft links」,是一個經過名稱指向另外一個不一樣文件的特殊的文件類型,是一個單獨的文件,有着不一樣於原文件(目標文件)的屬性,至關於Windows系統中的快捷方式。當對軟連接進行大多數操做(包括打開、讀取、寫入等等)時,系統內核會自動在軟連接的目標文件上執行;但某些操做,例如刪除,會直接對連接文件自己操做。
軟連接特性:
- 軟連接和目標文件不是同一個文件,節點號不一樣。
- 目標文件的刪除操做會影響軟連接文件。當連接文件被刪除時,不會對目標文件產生影響;當刪除目標文件/目錄時,因爲失去了目標指向,軟連接會失效,變成死鏈。
- 能跨分區建立軟連接。(使用命令 #hf -h 查看分區的大小是使用狀況的時候,掛載點那一行就是分區。)
- 命令語法: ln[-s][來源文件][目的文件]
- 命令描述: 創建軟連接
- 命令參數: -s 創建軟連接時,必需要加上 -s 選項,若是不加 -s 選項就是創建硬連接。
ln -s 源文件 目標文件
例如:# ln -s /root/123/.1.txt /tmp/123/12/1.txt
實例:
[root@cham2 tmp]# ln -s /tmp/yum.log /root/111/yum.log [root@cham2 tmp]# ls -l /root/111/ 總用量 16 -rw-r--r-- 1 root root 0 10月 25 17:20 12.tx~ -rw-r--r-- 1 root root 195 10月 25 17:23 12.txt -rw-r--r-- 1 root root 12288 10月 25 17:20 12_txt.swp drwxr-xr-x 2 root root 6 10月 25 17:16 222 -rw-r--r-- 1 root root 0 10月 25 17:20 4913 lrwxrwxrwx 1 root root 12 10月 26 20:32 yum.log -> /tmp/yum.log [root@cham2 tmp]# ls -l 總用量 16 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwxrwxrwx 1 cham cham 6 10月 26 20:02 321321 -rwx------ 1 root root 0 10月 25 15:24 3.txt -rwxrwxrwx 1 cham cham 1 10月 26 16:48 cham drwxrwxrwx 2 cham cham 6 10月 26 16:59 cham11 drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy drwxrwxrwx 2 user1 user1 6 10月 26 16:27 user1 -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [root@cham2 tmp]# [root@cham2 tmp]# ln -s /tmp/cham2 /root/111/cham3 [root@cham2 tmp]# ls -l !$ ls -l /root/111/cham3 lrwxrwxrwx 1 root root 10 10月 26 20:34 /root/111/cham3 -> /tmp/cham2 [root@cham2 tmp]# ls 2.txt cham chamlinux user1 321321 cham11 ks-script-JG2UJk yum.log 3.txt cham2 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy [root@cham2 tmp]# ln -s yum.log chamlinux.log [root@cham2 tmp]# ls -l 總用量 16 -rw-r--r-- 1 root root 2 10月 24 21:21 2.txt -rwxrwxrwx 1 cham cham 6 10月 26 20:02 321321 -rwx------ 1 root root 0 10月 25 15:24 3.txt -rwxrwxrwx 1 cham cham 1 10月 26 16:48 cham drwxrwxrwx 2 cham cham 6 10月 26 16:59 cham11 drw-r--r-x 2 user1 cham 19 10月 25 15:41 cham2 drwxr-xr-x 4 root root 28 10月 24 12:58 chamlinux lrwxrwxrwx 1 root root 7 10月 26 20:36 chamlinux.log -> yum.log -rwx------. 1 root root 836 10月 19 07:00 ks-script-JG2UJk drwx------ 3 root root 17 10月 24 12:21 systemd-private-5ec76fd91759498b901e85cba2554a24-vmtoolsd.service-H1l4Cy drwxrwxrwx 2 user1 user1 6 10月 26 16:27 user1 -rw-------. 1 user1 root 0 10月 19 06:55 yum.log [root@cham2 tmp]# mv chamlinux.log /root/111/ [root@cham2 tmp]# cd /root/111/ [root@cham2 111]# ls 12.tx~ 12.txt 12_txt.swp 222 4913 cham3 chamlinux.log yum.log [root@cham2 111]# ls -l 總用量 16 -rw-r--r-- 1 root root 0 10月 25 17:20 12.tx~ -rw-r--r-- 1 root root 195 10月 25 17:23 12.txt -rw-r--r-- 1 root root 12288 10月 25 17:20 12_txt.swp drwxr-xr-x 2 root root 6 10月 25 17:16 222 -rw-r--r-- 1 root root 0 10月 25 17:20 4913 lrwxrwxrwx 1 root root 10 10月 26 20:34 cham3 -> /tmp/cham2 lrwxrwxrwx 1 root root 7 10月 26 20:36 chamlinux.log -> yum.log lrwxrwxrwx 1 root root 12 10月 26 20:32 yum.log -> /tmp/yum.log [root@cham2 111]# cd /root/ [root@cham2 ~]# ls 111 11.txt 123 12.txt 1.txt 22.txt 234 2.txt anaconda-ks.cfg.1 [root@cham2 ~]# mv 111/chamlinux.log 123/ . [root@cham2 ~]# cd 123 [root@cham2 123]# ls -l 總用量 0 lrwxrwxrwx 1 root root 7 10月 26 20:36 chamlinux.log -> yum.log [root@cham2 123]# touch yum.log [root@cham2 123]# ls -l 總用量 0 lrwxrwxrwx 1 root root 7 10月 26 20:36 chamlinux.log -> yum.log -rw-r--r-- 1 root root 0 10月 26 20:39 yum.log [root@cham2 123]# ls chamlinux.log yum.log [root@cham2 123]# rm -f yum.log [root@cham2 123]# mv ../111/yum.log . 移動上級目錄到當前目錄 [root@cham2 123]# ls -l 總用量 0 lrwxrwxrwx 1 root root 7 10月 26 20:36 chamlinux.log -> yum.log lrwxrwxrwx 1 root root 12 10月 26 20:32 yum.log -> /tmp/yum.log [root@cham2 123]#
用 #hf -h 查看分區的大小和使用狀況,能夠看出/root用戶下的空間大小所剩很少,而 /目錄的空間很大。
好比/root下有一個 /root/dl.log 日誌文件,當dl.log日誌文件不停的寫入日誌時,所佔空間是比較大的,這時候咱們能夠把dl.log軟連接到/目錄 具體操做以下。
#cp /boot/dl.log /dl.log #rm -rf /boot/dl.log #ln -s /dl.log /boot/dl.log
上述命令說明:
1.把 /boot 下的 dl.log 日誌拷貝到/目錄下。
2.刪除 /boot 下的 dl.log 日誌。
3.把 / 目錄下的 /dl.log 軟連接到 /boot/dl.log 這樣的話,dl.log在日誌的時候,依然寫到了/boot/dl.log下。
- 當咱們創建軟連接的時候,目的文件不能夠存在,不然創建不成功。
- 全部軟連接自己就只能是一個文件!這個文件能夠指向目錄也能夠指向文件。
- 當咱們創建軟連接的時候,通常狀況下都是絕對路徑。若是創建一個相對路徑的軟連接,會有弊端!當咱們把全部的文件拷貝到另外一臺機器上,會發現源文件不存在。
硬連接
硬連接: 也即「hard link」,其本質爲現有文件的另外一個名字,所以硬連接和原文件是沒法區分的。從技術上講,它們共享相同的inode,而inode幾乎包含文件的全部信息,包括指向數據塊的直接/間接指針。
硬連接不支持目錄,僅支持文件,不能跨分區,可刪除,由於還有其餘文件使用了inode
- 建立一個文件,這個文件和另一個文件的inode號同樣,那麼這兩個文件相互爲硬連接文件。
- 只能對文件作硬連接,不能對目錄作硬連接。
- 不能跨系統分區建立硬連接。
- 只能對已存在的文件進行建立。
- 刪除一個硬連接文件並不影響其餘有相同inode號的文件。
[root@cham2 ~]# ln 1.txt 1_heard.txt [root@cham2 ~]# ln -s 1.txt 1_sorft [root@cham2 ~]# ls -l 總用量 16 drwxrwxr-- 3 root root 126 10月 26 20:41 111 -rw-rw-r-- 1 root root 135 10月 25 17:44 11.txt drwxr-xr-x 2 root root 42 10月 26 20:41 123 -rw-r--r-- 1 root root 65 10月 25 17:20 12.txt -rw-r--r-- 2 root root 0 10月 25 17:31 1_heard.txt lrwxrwxrwx 1 root root 5 10月 26 21:31 1_sorft -> 1.txt -rw-r--r-- 2 root root 0 10月 25 17:31 1.txt -rw-r--r-- 1 root root 0 10月 25 17:07 22.txt drwxrwxr-x 4 root user1 64 10月 26 14:09 234 -rwx------ 1 root root 1008 10月 25 16:41 2.txt -rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg.1 [root@cham2 ~]# ls -l 總用量 16 drwxrwxr-- 3 root root 126 10月 26 20:41 111 -rw-rw-r-- 1 root root 135 10月 25 17:44 11.txt drwxr-xr-x 2 root root 42 10月 26 20:41 123 -rw-r--r-- 1 root root 65 10月 25 17:20 12.txt -rw-r--r-- 2 root root 0 10月 25 17:31 1_heard.txt lrwxrwxrwx 1 root root 5 10月 26 21:31 1_sorft -> 1.txt -rw-r--r-- 2 root root 0 10月 25 17:31 1.txt -rw-r--r-- 1 root root 0 10月 25 17:07 22.txt drwxrwxr-x 4 root user1 64 10月 26 14:09 234 -rwx------ 1 root root 1008 10月 25 16:41 2.txt -rw-r--r-- 2 root root 0 10月 26 21:33 88_heard.txt lrwxrwxrwx 1 root root 6 10月 26 21:34 88_sorft.txt -> 88.txt -rw-r--r-- 2 root root 0 10月 26 21:33 88.txt -rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg.1 [root@cham2 ~]# ls -i 33575631 111 33575641 1_heard.txt 16783440 234 33575648 88.txt 33575016 11.txt 33575647 1_sorft 16777669 2.txt 33574987 anaconda-ks.cfg.1 30154 123 33575641 1.txt 33575648 88_heard.txt 33575640 12.txt 33575633 22.txt 33575642 88_sorft.txt [root@cham2 ~]# rm -f 1.txt [root@cham2 ~]# ls -l 總用量 16 drwxrwxr-- 3 root root 126 10月 26 20:41 111 -rw-rw-r-- 1 root root 135 10月 25 17:44 11.txt drwxr-xr-x 2 root root 42 10月 26 20:41 123 -rw-r--r-- 1 root root 65 10月 25 17:20 12.txt -rw-r--r-- 1 root root 0 10月 25 17:31 1_heard.txt lrwxrwxrwx 1 root root 5 10月 26 21:31 1_sorft -> 1.txt -rw-r--r-- 1 root root 0 10月 25 17:07 22.txt drwxrwxr-x 4 root user1 64 10月 26 14:09 234 -rwx------ 1 root root 1008 10月 25 16:41 2.txt -rw-r--r-- 2 root root 0 10月 26 21:33 88_heard.txt lrwxrwxrwx 1 root root 6 10月 26 21:34 88_sorft.txt -> 88.txt -rw-r--r-- 2 root root 0 10月 26 21:33 88.txt -rw-------. 1 root root 1422 10月 19 07:00 anaconda-ks.cfg.1 [root@cham2 ~]# ls -i 1_heard.txt 33575641 1_heard.txt [root@cham2 ~]# ln 111 cham111 ln: "111": 不容許將硬連接指向目錄 [root@cham2 ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 17G 1.1G 16G 7% / devtmpfs 483M 0 483M 0% /dev tmpfs 493M 0 493M 0% /dev/shm tmpfs 493M 6.8M 486M 2% /run tmpfs 493M 0 493M 0% /sys/fs/cgroup /dev/sda1 187M 109M 79M 59% /boot tmpfs 99M 0 99M 0% /run/user/0 [root@cham2 ~]# ls -i /boot/ 71 config-3.10.0-514.el7.x86_64 67 grub 131136 grub2 76 initramfs-0-rescue-0f3cf64915c04d4e93e4dae2684b907d.img 75 initramfs-3.10.0-514.el7.x86_64.img 194501 initramfs-3.10.0-514.el7.x86_64kdump.img 74 initrd-plymouth.img 72 symvers-3.10.0-514.el7.x86_64.gz 70 System.map-3.10.0-514.el7.x86_64 77 vmlinuz-0-rescue-0f3cf64915c04d4e93e4dae2684b907d 73 vmlinuz-3.10.0-514.el7.x86_64 [root@cham2 ~]# ln /boot/config-3.10.0-514.el7.x86_64 /tmp/config.1 ln: 沒法建立硬連接"/tmp/config.1" => "/boot/config-3.10.0-514.el7.x86_64": 無效的跨設備鏈接 [root@cham2 ~]# ls /boot/ config-3.10.0-514.el7.x86_64 grub grub2 initramfs-0-rescue-0f3cf64915c04d4e93e4dae2684b907d.img initramfs-3.10.0-514.el7.x86_64.img initramfs-3.10.0-514.el7.x86_64kdump.img initrd-plymouth.img symvers-3.10.0-514.el7.x86_64.gz System.map-3.10.0-514.el7.x86_64 vmlinuz-0-rescue-0f3cf64915c04d4e93e4dae2684b907d vmlinuz-3.10.0-514.el7.x86_64 [root@cham2 ~]# ls / bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [root@cham2 ~]# ls -i / 95 bin 16777281 etc 82 lib64 33584771 opt 8124 run 1 sys 50331713 var 64 boot 50331740 home 83 media 1 proc 99 sbin 16777288 tmp 1026 dev 98 lib 16777681 mnt 33574977 root 50331741 srv 33584746 usr [root@cham2 ~]#
硬連接:
軟連接: