Linux運維63期day14

操作系統(tǒng)文件屬性

01.文件屬性組成部分
[root@qiwangyu ~]# ll -i /etc/
總用量 1100
201865030 d rwxr-xr-x. 3 root root 101 7月 9 14:25 abrt
67416656 - rw-r--r--. 1 root root 16 7月 9 14:29 adjtime
67157548 - rw-r--r--. 1 root root 1518 6月 7 2013 aliases
67108933 - rw-r--r--. 1 root root 12288 7月 9 14:35 aliases.db
01 02 03 04 05 06 07 08 09
01:文件inode號碼 inode(index node)==書的目錄
02:文件類型信息 文件類型和文件擴展名(.txt .dak)無關(guān)
03:文件權(quán)限信息 r-read 讀 w-write 寫 x-execute 可執(zhí)行(setup.exe)
04:文件硬鏈接數(shù) 相當于查看數(shù)據(jù)的多個門
05:文件所屬用戶 (屬主) 監(jiān)護人 管理數(shù)據(jù)的最高權(quán)力 (最高權(quán)力)
06:文件所屬組用戶(屬組) 親人 管理數(shù)據(jù)信息 (一般權(quán)力)
其他用戶 隔壁老王 管理數(shù)據(jù)信息 (最低權(quán)力)
07:文件容量大小 默認顯示字節(jié)信息 ls -lh
08:文件時間信息 文件修改時間信息
以上信息都是屬于文件屬性信息

[root@qiwangyu ~]# ll -h /etc/services
-rw-r--r-- 1 root root 655K 7月 18 09:16 /etc/services
[root@qiwangyu ~]# ll /etc/ -d
drwxr-xr-x. 83 root root 8192 7月 18 15:29 /etc/
[root@qiwangyu ~]# ll /etc/ -dh
drwxr-xr-x. 83 root root 8.0K 7月 18 15:29 /etc/
目錄的大小不決定文件的大小
09:文件名稱信息 文件名稱不屬于文件屬性

  1. 文件屬性詳細說明---文件類型
    oldboy.txt oldboy.jpg Linux中不關(guān)注文件擴展名 無論是什么都是可編輯的文件
    文件類型說明:文件類型查看命令 file
    PS:Linux系統(tǒng)中一切皆文件
    普通文件 - 文本文件;二進制文件(命令文件);腳本文件(.sh .py) 數(shù)據(jù)文件(壓縮文件)
    [root@qiwangyu ~]# ll /usr/bin/cat
    -rwxr-xr-x. 1 root root 54160 10月 31 2018 /usr/bin/cat
    文本文件:可編輯
    [root@qiwangyu ~]# file anaconda-ks.cfg
    anaconda-ks.cfg: ASCII text
    命令文件:
    ELF 64-bit LSB executable,
    腳本文件:
    數(shù)據(jù)文件:
    gzip compressed data, from Unix
    目錄文件 d directory
    鏈接文件 l 軟連接文件(快捷方式) lrwxrwxrwx
    設(shè)備文件 c 字符流設(shè)備文件 character cat /dev/urandom 產(chǎn)生大量字符 生成隨機碼
    b 塊設(shè)備文件 block 存儲設(shè)備文件信息
    [root@qiwangyu ~]# ll /dev/sr0
    brw-rw---- 1 root cdrom 11, 0 7月 17 10:53 /dev/sr0
    [root@qiwangyu ~]# ll /dev/sda3
    brw-rw---- 1 root disk 8, 3 7月 17 10:53 /dev/sda3
    套接字文件 s socket(網(wǎng)絡(luò)通訊 網(wǎng)絡(luò)開發(fā))

    利用擴展名標識文件類型
    .log 日志
    /conf 配置文件
    .sh 腳本文件
    .py Python腳本文件
    .tar.gz 壓縮文件

    解鎖文件命令:
    file ---查看文件類型
    which ---查看命令文件信息
    whereis ---顯示命令路徑信息和相關(guān)其他新文件(幫助手冊文件)路徑信息
    locate ---查詢文件(任意文件)所在路徑信息
    默認centos沒有這個命令 yum provides locate -->yum install -y mlocate
    第一步:創(chuàng)建一個文件索引數(shù)據(jù)庫
    updatedb 更新locate命令下的數(shù)據(jù)庫信息
    第二部:找文件

find ---擅長從系統(tǒng)中獲取文件
遞歸查找文件
說明:find命令參數(shù)基本都是短格式 一個 -
根據(jù)文件名稱獲取文件:
find 找尋文件路徑 找尋文件的條件
find /opt -name "oldboy.sh"
find /opt -name "old*" *為匹配符號
忽略大小寫查找
find /opt -iname "oldboy.sh"
根據(jù)文件類型查找文件:
-type
find /opt -type f
find /opt -type f -name "oldboy.sh" ---多個查找條件是并且關(guān)系
根據(jù)指定目錄層級查找文件
find /opt -maxdepth 1 -type f -name "oldboy.sh" ---根據(jù)制定目錄最大層級查找數(shù)據(jù)
find /opt -mindepth 1 -type f -name "oldboy.sh" ---根據(jù)制定目錄最小層級查找數(shù)據(jù)
文件類型有什么:man find type
f file 找尋普通文件
d directory 找尋目錄文件
l link 找尋軟連接文件
c 字符流設(shè)備文件
b 塊設(shè)備文件
s 套接字文件
根據(jù)指定文件大小查找文件:
系統(tǒng)中有大文件數(shù)據(jù)占用磁盤空間?
find / -type f -size +50M ---大于50M的文件找出來
find / -type f -size 50M ---等于50M的文件找出來
find / -type f -size -50M ---小于50M的文件找出來
查找文件根據(jù)文件大小信息,文件尺寸單位
b' for 512-byte blocks (this is the default if no suffix is used)c' for bytes
w' for two-byte wordsk' for Kilobytes (units of 1024 bytes)
M' for Megabytes (units of 1048576 bytes)G' for Gigabytes (units of 1073741824bytes)

tree
tree -L n 目錄路徑 ---一層一層的看目錄層級(全看)
tree -L -d 目錄路徑 ---只顯示目錄層級中的目錄信息

tar ---等價于Windows rar zip軟件,壓縮命令
如何壓縮數(shù)據(jù)(文本數(shù)據(jù) 腳本文件) 小文件沒意義壓縮 已經(jīng)壓縮過的
# tar 參數(shù) 生成壓縮包文件(路徑信息) 將什么文件進行壓縮
tar zcvf /opt/壓縮.tar.gz /tmp/services zcvf參數(shù)f位置不變,其他三個位置隨意
z ---壓縮文件的方式 gzip
c ---create創(chuàng)建 創(chuàng)建一個壓縮包文件
v ---詳細顯示壓縮的過程
f ---指定壓縮包的路徑(必須卸載所有參數(shù)最后)
檢查壓縮包數(shù)據(jù)
方式一:不解壓直接檢查
tar tf /opt/壓縮.tar.gz
t ---不解壓,檢查壓縮包里面的內(nèi)容
方法二:解壓檢查數(shù)據(jù)
tar xvf /opt/壓縮.tar.gz 默認解壓到當前目錄
x ---解壓指定壓縮包

指定解壓數(shù)據(jù)路徑
tar xf /opt/oldboy02.tar.gz -C /opt/
-C ---指定解壓的路徑

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容