利用stat命令擷取Linux檔案系統和檔案的詳細狀態資訊

來源:互聯網
上載者:User

標籤:stat   stat命令詳解   stat檔案   

用途:stat命令用於顯示檔案或檔案系統的狀態資訊,來自於coreutils軟體包,一般系統內建此命令工具,它能擷取與檔案系統及檔案相關的許多資訊,具體用途見stat的功能選項。這些資訊包括inode、atime、ctime、mtime、檔案(系統)類型、許可權、塊大小、符號串連等。

文法:stat [OPTION]... FILE... , 可通過stat --help或man stat擷取它的協助資訊

功能選項:功能選項需要結合-c參數使用,如利用stat擷取檔案的inode資訊,則使用stat –c%i /filepath/filename可以獲得/filepath/filename檔案的inode編號。

針對檔案系統:

注意:當目標檔案是檔案系統時需要使用-f選項,如利用stat擷取檔案系統的inode數量,則使用stat –f –c%c /filepath/filename可以獲得/filepath/filename檔案系統的inode數量。

%a Free blocks available to non-superuser 顯示非超級使用者的剩餘塊資訊
%b Total data blocks in file system 檔案系統上的資料區塊總數
%c Total file nodes in file system 檔案系統中inode總數
%d Free file nodes in file system 檔案系統中剩餘的inode數量
%f Free blocks in file system 檔案系統中剩餘的塊
%C SELinux security context string SELinux安全內容資訊
%i File System ID in hex 十六進位的檔案系統ID
%l Maximum length of filenames 檔案名稱的最大長度
%n File name 檔案名稱
%s Block size (for faster transfers) 塊大小(為了更快的傳輸(速度))
%S Fundamental block size (for block counts) 最小的塊大小
%t Type in hex 十六進位檔案系統類型
%T Type in human readable form 人類可閱讀的檔案系統類型

針對檔案:

%a Access rights in octal 八進位檔案存取權限
%A Access rights in human readable form 適合人類閱讀的檔案存取權限
%b Number of blocks allocated (see %B) 分配的塊數量
%B The size in bytes of each block reported by %b 塊大小
%C SELinux security context string SELinux安全內容資訊
%d Device number in decimal 十進位裝置號
%D Device number in hex 十六進位裝置號
%f Raw mode in hex 十六進位顯示Raw模式
%F File type 擷取檔案類型
%g Group ID of owner 檔案所有者的組ID
%G Group name of owner 檔案所有者的組名稱
%h Number of hard links 檔案的硬串連數量
%i Inode Number 檔案的inode號
%n File name 檔案名稱
%N Quoted file name with dereference if symbolic links 如果是符號連結則顯示映射關係
%o I/O block size I/O塊大小
%s Total size, in bytes 檔案總大小
%t Major device type in hex 十六進位的首要裝置類型
%T Minor device type in hex 十六進位的次要裝置類型
%u User ID of owner 檔案所有者的使用者ID
%U User name of owner 檔案所有者的使用者名稱稱
%x Time of last access 檔案最後的訪問時間(人類可閱讀)
%X Time of last access as seconds since Epoch 檔案最後的訪問時間(UNIX時間)
%y Time of last modification 檔案最後的內容更改時間(人類可閱讀)
%Y Time of last modification as seconds since Epoch 檔案最後的內容更改時間(UNIX時間)
%z Time of last change 檔案最後的改變(除了內容還包括許可權資訊)時間(人類可閱讀)
%Z Time of last change as seconds since Epoch 檔案最後的改變(除了內容還包括許可權資訊)時間(UNIX時間)

注意:符號連結檔案的內容變化不影響mtime和ctime,只對目標檔案有影響。

--end--

本文出自 “通訊,我的最愛” 部落格,請務必保留此出處http://dgd2010.blog.51cto.com/1539422/1629945

利用stat命令擷取Linux檔案系統和檔案的詳細狀態資訊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.