1. 程式人生 > >linux stat命令引數及用法詳解

linux stat命令引數及用法詳解

功能說明:顯示inode內容。
語  法:stat [檔案或目錄]
補充說明:stat以文字的格式來顯示inode的內容。

ls 命令及其許多引數提供了一些非常有用的檔案資訊。另一個不太為人所熟知的命令 stat 提供了一些更為有用的資訊。 

下面演示瞭如何對可執行檔案“oracle”(位於 $ORACLE_HOME/bin 目錄下)使用此命令。  
 
# cd $ORACLE_HOME/bin   
# stat oracle   
  File: `oracle'   
  Size: 93300148        Blocks:182424     IO Block:4096   Regular File   
Device: 343h/835d       Inode: 12009652    Links: 1       
Access: (6751/-rwsr-s--x)  Uid:(  500/  oracle)   Gid:(  500/     dba)   
Access: 2006-08-04 04:30:52.000000000 -0400  
Modify: 2005-11-02 11:49:47.000000000 -0500  
Change: 2005-11-02 11:55:24.000000000 -0500  
注意使用該命令獲得的資訊:除了通常的檔案大小(也可以使用 ls -l 命令獲得)以外,您還獲得了該檔案佔用的塊數。通常的 Linux 塊大小為 512 位元組,因此一個大小為 93,300,148 位元組的檔案將佔用 (93300148/512=) 182226.85 個塊。由於塊都是完整佔用,因此該檔案使用了一些整數個數的塊。無需猜測就可以獲得確切的塊數。 

您還可以從以上輸出中獲得檔案所有權的 GID 和 UID,以及許可權的八進位制表示形式 (6751)。如果要將檔案恢復到它現在具有的相同許可權,可以使用 chmod 6751 oracle,而不是顯式拼寫這些許可權。 

以上輸出最有用的部分是檔案訪問時間戳資訊。該輸出顯示,該檔案被訪問的時間是 2006-08-04 04:30:52(顯示在“Access:”的旁邊),即 2006 年 8 月 4 日上午 4:30:52。這是某個人開始使用資料庫的時間。該檔案的date.html' target='_blank'>修改時間是 2005-11-02 11:49:47(顯示在“Modify:”的旁邊)。最後,“Change:”旁邊的時間戳顯示檔案狀態更改的時間。 

stat 命令的修改符 -f 顯示了有關檔案系統(而非檔案)的資訊: 
 
# stat -f oracle   
  File: "oracle"  
    ID: 0        Namelen:255     Type:ext2/ext3   
Blocks: Total: 24033242   Free: 15419301   Available: 14198462   Size: 4096  
Inodes: Total: 12222464   Free: 12093976     
  
另一個選項 -t 顯示了完全相同的資訊,只不過是在一行中顯示的:    
  
# stat -t oracle    
oracle 93300148 182424 8de9 500 500 343 12009652 1 0 0 1154682061    
1130950187 1130950524 4096  

Everything in Unix is treated as files. This includes devices, directories and sockets — all of these are files. Stat command

 displays file or filesystem status as explained in this article.

File Stat – Display Information About File

For example, to find out more information about 101hacks.txt file, execute the stat command as shown below.

$ stat 101hacks.txt
  File: `/home/sathiyamoorthy/101hacks.txt'
  Size: 854       	Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d	Inode: 1058122     Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/ sathiya)   Gid: ( 1000/ sathiya)
Access: 2009-06-28 19:29:57.000000000 +0530
Modify: 2009-06-28 19:29:57.000000000 +0530
Change: 2009-06-28 19:29:57.000000000 +0530

Details of Linux Stat Command Output

  • File: `/home/sathiyamoorthy/101hacks.txt’ – Absolute path name of the file.
  • Size: 854 – File size in bytes.
  • Blocks: 8 – Total number of blocks used by this file.
  • IO Block: 4096 – IO block size for this file.
  • regular file – Indicates the file type. This indicates that this is a regular file. Following are available file types.
    • regular file. ( ex: all normal files ).
    • directory. ( ex: directories ).
    • socket. ( ex: sockets ).
    • symbolic link. ( ex: symbolic links. )
    • block special file ( ex: hard disk ).
    • character special file. ( ex: terminal device file ).
  • Device: 801h/2049d  – Device number in hex and device number in decimal
  • Inode: 1058122 – Inode number is a unique number for each file which is used for the internal maintenance by the file system.
  • Links: 1 – Number of links to the file
  • Access: (0600/-rw——-): Access specifier displayed in both octal and character format. Let us see explanation about both the format.
  • Uid: ( 1000/ sathiya) – File owner’s user id and user name are displayed.
  • Gid: ( 1000/ sathiya) – File owner’s group id and group name are displayed.
  • Access: 2009-06-28 19:29:57.000000000 +0530 – Last access time of the file.
  • Modify: 2009-06-28 19:29:57.000000000 +0530 – Last modification time of the file.
  • Change: 2009-06-28 19:29:57.000000000 +0530 – Last change time of the inode data of that file.

Dir Stat – Display Information About Directory

You can use the same command to display the information about a directory as shown below.

$ stat /home/ramesh
File: `/home/ramesh'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 803h/2051d Inode: 5521409 Links: 7
Access: (0755/drwxr-xr-x) Uid: ( 401/ramesh) Gid: ( 401/ramesh)
Access: 2009-01-01 12:17:42.000000000 -0800
Modify: 2009-01-01 12:07:33.000000000 -0800
Change: 2009-01-09 12:07:33.000000000 -0800

Details of File Permission:

File Permission In Octal Format

This information about the file is displayed in the Access field when you execute stat command. Following are the values for read, write and execute permission in Unix.


相關推薦

linux stat命令引數用法

功能說明:顯示inode內容。 語  法:stat [檔案或目錄] 補充說明:stat以文字的格式來顯示inode的內容。 ls 命令及其許多引數提供了一些非常有用的檔案資訊。另一個不太為人所熟知的命令 stat 提供了一些更為有用的資訊。  下面演示瞭如何對可執行檔案“

linux su命令引數用法

linux su 命令 建議大家切換使用者的時候 使用 su - root 這樣,否則可能發現某些命令執行不了 關於su 、su - 及 sudo的區別 請往下看 1.命令作用 su的作用是變更為其它使用者的身份,超級使用者除外,需要鍵入該使用者的

linux grep命令引數用法---linux管道命令grep

今天為了查詢檔案中某段字元,找了好久,最後成功使用指令: find . -name "*.cpp" |xargs grep -in “get_itemInfo” | grep -v obd_c 找出了自己想要的檔案。(指定cpp結尾的檔案,找出有get_itemInfo字

linux telnet命令引數用法

lnet [-8acdEfFKLrx][-b<主機alias.html' target='_blank'>別名>][-e<脫離字元>][-k<域名>][-l<使用者名稱稱>][-n<記錄檔案>][-S<

Linux如何檢視系統當前登入使用者資訊,linux su命令引數用法(linux切換使用者命令)

作為系統管理員,你可能經常會(在某個時候)需要檢視系統中有哪些使用者正在活動。有些時候,你甚至需要知道他(她)們正在做什麼。本文為我們總結了4種檢視系統使用者資訊(通過編號(ID))的方法。 1. 使用w命令檢視登入使用者正在使用的程序資訊 w命令用於顯示已經登入系統的使用

linux kill命令引數用法--linux終止程序命令

Linux kill 命令使用詳解 功能說明:刪除執行中的程式或工作。 語  法:kill [-s <資訊名稱或編號>][程式] 或 kill [-l <資訊編號>] 補充說明:kill可將指定的資訊送至程式。預設的資訊為SIGTERM(15),可

[ARM-Linux開發]linux dmesg命令引數用法(linux顯示開機資訊命令)

功能說明:顯示開機資訊。語  法:dmesg [-cn][-s <緩衝區大小>]補充說明:kernel會將開機資訊儲存在ring buffer中。您若是開機時來不及檢視資訊,可利用dmesg來檢視。開機資訊亦儲存在/var/log目錄中,名稱為dmesg的檔案

linux mlabel命令引數用法---設定磁碟的標籤

Linux mlabel命令用法詳解命令名稱:mlabel ,使用許可權:所有使用者,使用方式:mlabel [-vcs] drive:[new_label]說明: 本程式可設定磁碟的標籤 (Label)。 如果磁碟上設定過標籤,mlabel 會將他顯示給使用者。如果

Linux set命令引數用法--Linux設定環境變數命令

功能說明:設定shell。 語  法:set [+-abCdefhHklmnpPtuvx] 補充說明:用set 命令可以設定各種shell選項或者列 出shell變數.單個選項設定常用的特性.在某些選項之後-o引數將特殊特性開啟.在某些選項之後使用+o引數將關閉某些特性,不

mkisofs引數用法---linux製作ISO啟動盤命令

最簡單的光碟生成ISO-----------只有-o –v兩個基本引數 [[email protected] home]# ls clamav  guan  guant  iei  simscan  yu [[email protected] home]# mkisofs -o test.

linux stat命令三個時間

stat   檔案或檔案系統的詳細資訊 -f  不顯示檔案本身的資訊,顯示檔案所在檔案系統的資訊 -L  顯示符號連結 -t  簡潔模式,只顯示摘要資訊 Access:  顯示的時間是我們最後一次訪問的時間 每次訪問,修改access時間都會更新,如cat,

linux ping命令引數用法

語  法:ping [-dfnqrRv][-c<完成次數>][-i<間隔秒數>][-I<網路介面>][-l<前置載入>][-p<範本樣式>][-s<資料包大小>][-t<存活數值>][主機名

linux cp命令參數用法---linux 復制文件命令cp

linux file linux cp命令參數及用法詳解---linux 復制文件命令cp [root@Linux ~]# cp [-adfilprsu] 來源檔(source) 目的檔(destination)[root@linux

Linux命令--ss命令引數使用

  ss是Socket Statistics的縮寫。顧名思義,ss命令可以用來獲取socket統計資訊,它可以顯示和netstat類似的內容。但ss的優勢在於它能夠顯示更多更詳細的有關TCP和連線狀態的資訊,而且比netstat更快速更高效。 一、ss命令的引數如下 Usage: ss [ OPTI

(轉)Linux命令之Ethtool用法

如果 size ram phy 基本設置 速度 終端 網卡驅動 sed Linux命令之Ethtool用法詳解 原文:http://www.linuxidc.com/Linux/2012-01/52669.htm Linux/Unix命令之Ethtool描述:Eth

Linux使用者,組管理命令整理例項

使用者,組 相關檔案: /etc/passwd 使用者相關資訊 /etc/login.defs 設定使用者建立時預設相關資訊 /etc/defualt/useradd 使用者新增時會建立的相關資訊設定 /etc/skel

Linux rpm 命令參數使用[介紹和應用]

使用詳解 gtk ont 由於 ins toolbar root 重新整理 完成後 參考來源:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/10/08/2203153.html rpm 執行安裝包二進制包(Bi

Linux RPM 命令參數使用

linux命令 rpmrpm 執行安裝包二進制包(Binary)以及源代碼包(Source)兩種。二進制包可以直接安裝在計算機中,而源代碼包將會由 RPM自動編譯、安裝。源代碼包經常以src.rpm作為後綴名。常用命令組合:-ivh:安裝顯示安裝進度--install--verbose--hash-Uvh:升

【轉】Linux rpm 命令參數使用[介紹和應用]

binary 包管理 samba cpio 詳解 -- hash pos 升級 RPM是RedHat Package Manager(RedHat軟件包管理工具)類似Windows裏面的“添加/刪除程序” rpm 執行安裝包二進制包(Binary)以及源代碼包(So

Java Web專案部署至Linux伺服器的步驟問題

        部門接手公司內部需求的一個小專案,從設計到研發自主完成,期間遇到了不少困難。部署過程也是坎坷,特此寫篇文章記錄一下,也為新手們填個坑~高手請跳過~~ 一、部署環境搭建(此步驟參考)