linux下stat程式簡介__linux

來源:互聯網
上載者:User

1、簡介

     stat程式可以顯示檔案或者檔案系統的資訊。

2、參數

Usage: stat [OPTION] FILE...  
Display file or filesystem status.  
  -f, --filesystem      display filesystem status instead of file status  
  -c  --format=FORMAT   use the specified FORMAT instead of the default  
  -L, --dereference     follow links  
  -Z, --context         print the security context information if available  
  -t, --terse           print the information in terse form  
      --help     display this help and exit  
      --version  output version information and exit  
      
The valid format sequences for files (without --filesystem):  
  %A   Access rights in human readable form  
  %a   Access rights in octal  
  %B   The size in bytes of each block reported by `%b'  
  %b   Number of blocks allocated (see %B)  
  %D   Device number in hex  
  %d   Device number in decimal  
  %F   File type  
  %f   Raw mode in hex  
  %G   Group name of owner  
  %g   Group ID of owner  
  %h   Number of hard links  
  %i   Inode number  
  %N   Quoted File name with dereference if symbolic link  
  %n   File name  
  %o   IO block size  
  %s   Total size, in bytes  
  %T   Minor device type in hex  
  %t   Major device type in hex  
  %U   User name of owner  
  %u   User ID of owner  
  %X   Time of last access as seconds since Epoch  
  %x   Time of last access  
  %Y   Time of last modification as seconds since Epoch  
  %y   Time of last modification  
  %Z   Time of last change as seconds since Epoch  
  %z   Time of last change  
  
Valid format sequences for file systems:  
  %a   Free blocks available to non-superuser  
  %b   Total data blocks in file system  
  %c   Total file nodes in file system  
  %d   Free file nodes in file system  
  %f   Free blocks in file system  
  %C - Security context in SELinux  
  %i   File System id in hex  
  %l   Maximum length of filenames  
  %n   File name  
  %s   Optimal transfer block size  
  %T   Type in human readable form  
  %t   Type in hex  

3、樣本

1)顯示指定檔案的狀態資訊

stat /root/.bashrc 
  File: `/root/.bashrc'
  Size: 470             Blocks: 8          IO Block: 4096   regular file
Device: 301h/769d       Inode: 2195486     Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2013-05-27 23:36:35.000000000 +0800
Modify: 2013-04-06 10:37:03.000000000 +0800
Change: 2013-04-06 10:37:03.000000000 +0800


2)顯示檔案系統狀態資訊

 stat -f /root/.bashrc 
  File: "/root/.bashrc"
    ID: 0        Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 5077005    Free: 4277190    Available: 4015131
Inodes: Total: 5242880    Free: 5132870



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.