Linux 隱藏許可權、特殊許可權、軟連結、硬連結
隱藏許可權lsattr_chattr;特殊許可權set_uid,set_gid,stick_bit;軟連結/硬連結;find命令,linux和windows檔案互傳
1、隱藏許可權lsattr_chattr
chattr 在Linux檔案系統上更改檔案屬性
chattr +i 新增‘i'隱藏屬性;不能更改檔案或目錄 防止刪除檔案或目錄
chattr -i 解除’i'隱藏屬性
chattr +a 只能增加資料,而不能刪除,只有 root 才能設定這個屬性
lsattr 檢視檔案的隱藏屬性
lsattr -a 將隱藏檔案的屬性也列出來;
lsattr -R 連同子目錄的資料也一併列出來!
lsattr -d 檢視目錄檔案本身的隱藏屬性
2.1、特殊許可權set_uid 用在使用者許可權上
set_uid 除所有者外普通使用者在執行時,臨時擁有所有者許可權(前提檔案型別是二進位制或執行檔案)
s 即為set_uid
chmod u+s 新增特殊許可權
chmod u-s 解除特殊許可權
2.2、特殊許可權set_gid 用在組許可權上
set_gid 普通使用者臨時擁有所屬組使用者許可權
chmod g+s 新增特殊許可權(新增許可權後建立的檔案或目錄與上一級的所屬組一致)
chmod g-s 解除特殊許可權
2.3、特殊許可權stick_bit
stick_bit 防止被別的使用者刪除 (PS : root使用者除外 , 它是超級管理員 , 防止不了,更改成777許可權也無效)
chmod o+t 目錄
[[email protected] /]# ls -ld /tmp/
drwxrwxrwt. 15 root root 4096 5月 13 20:50 /tmp/
附:whoamin 檢視使用者 su - 使用者 更改使用者
3、軟連結/硬連結檔案
軟連結 儘量使用絕對路徑
ln -s /原檔案或目錄 /目標檔案或目錄(軟連結檔案或目錄)
[[email protected] /]# ln -s /tmp/linux /root/linux1
[[email protected] /]# ls -l /root/
總用量 4
-rw-------. 1 root root 1418 5月 8 00:15 anaconda-ks.cfg
lrwxrwxrwx. 1 root root 10 5月 13 23:13 linux1 -> /tmp/linux
硬連結 只能給檔案做硬連結,不能給目錄做硬連結
硬連結可刪除,因檔案存在inode裡;
ln 檔案 硬連結檔案 建立硬連結
注:檔案只能在同分區內建立硬連結;不能跨分割槽;因分割槽有獨立的inode;
4、find
ctrl 常用組合鍵
Ctrl+l 清屏
Ctrl+d 結束或退出
Ctrl+c 中斷
Ctrl+u 清除剪下游標之前的內容
Ctrl+a 切換到命令列開始
Ctrl+e 切換到命令列末尾
find - name 按檔名查詢
例:[[email protected] ~]# find -name "test"
./test
./mulu/test
[[email protected] ~]# find -name "test*" 模糊查詢
./test
./test3
./mulu/test
./mulu/test1
./mulu/test2
[[email protected] /]# find /root -type f -name "te*" 按檔案型別查詢
/root/test
/root/test3
/root/linux/test
/root/linux/test1
/root/linux/test2
檔案型別:d目錄;f一般檔案;l連結檔案;
[[email protected] /]# find /root -type d
/root
/root/.ssh
/root/linux
[[email protected] /]# find /root -type l
/root/linux1
[[email protected] /]# find /root -type f
/root/.bash_logout
/root/.bash_profile
/root/.bashrc
/root/.cshrc
/root/.tcshrc
/root/anaconda-ks.cfg
/root/.bash_history
/root/.ssh/authorized_keys
/root/test
/root/test3
/root/linux/test
/root/linux/test1
/root/linux/test2
按時間查詢 -mtime +n (天);-mmin +n(分鐘)
[[email protected] /]# find /tmp -mtime -1
/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vgauthd.service-SI2BL0
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vgauthd.service-SI2BL0/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J/tmp/vmware-root
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-chronyd.service-CvNdBt
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-chronyd.service-CvNdBt/tmp
[[email protected] /]# find /tmp -mmin -300
/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vgauthd.service-SI2BL0
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vgauthd.service-SI2BL0/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J/tmp
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-vmtoolsd.service-QfqS5J/tmp/vmware-root
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-chronyd.service-CvNdBt
/tmp/systemd-private-7257c2f23b4a438e8863f4365e11a599-chronyd.service-CvNdBt/tmp
-inum +inode 按inode號查詢
-size +/-單位(c、k)按檔案大小查詢
-exec:一旦find命令匹配到了相應的檔案,就可以用-exec選項中的命令對其進行操作;
格式: -exec 命令 {} \;exec選項後面跟隨著所要執行的命令,然後是 {}, \, ;
root檔案下所有大於1k檔案並列出詳細資訊
[[email protected] /]# find /root -type f -size +1k -exec ls -l {} \;
-rw-------. 1 root root 1418 5月 8 00:15 /root/anaconda-ks.cfg
-rw-------. 1 root root 4689 5月 15 14:04 /root/.bash_history
5、linux和windows檔案互傳
Xftp
[[email protected] /]# yum install -y lrzsz 先安裝lrzsz包;
從linux上傳到windows
安裝完用用sz +檔案 回車 上傳檔案 到windows桌面
從windows下載到linux