Linux - 查看文件信息的三個命令


ls命令 - list directory contents

顯示文件詳細信息:ls -l <file name>

file命令 — determine file type

determine file type :file <file name>
output MIME type strings (--mime-type and --mime-encoding) :file -i <file name>

stat命令 - display file or file system status

顯示文件狀態信息:stat <file name>
顯示文件在系統的狀態信息:stat -f <file name>
簡明顯示文件的狀態信息:stat -t <file name>

示例:查看“/usr/bin/bash”文件

[anliven@CentOS7 ~]$ ls -l /usr/bin/bash
-rwxr-xr-x. 1 root root 960392 Aug  3  2016 /usr/bin/bash
[anliven@CentOS7 ~]$ 
[anliven@CentOS7 ~]$ file /usr/bin/bash
/usr/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=b3078871b93598006980c166e4cd885b60a4f6af, stripped
[anliven@CentOS7 ~]$ 
[anliven@CentOS7 ~]$ file -i /usr/bin/bash
/usr/bin/bash: application/x-executable; charset=binary
[anliven@CentOS7 ~]$ 
[anliven@CentOS7 ~]$ stat /usr/bin/bash
  File: ‘/usr/bin/bash’
  Size: 960392    	Blocks: 1880       IO Block: 4096   regular file
Device: fd00h/64768d	Inode: 5446        Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2017-12-01 23:00:01.150409830 +0800
Modify: 2016-08-03 00:00:07.000000000 +0800
Change: 2017-04-23 08:08:44.204147902 +0800
 Birth: -
[anliven@CentOS7 ~]$ 
[anliven@CentOS7 ~]$ stat -f /usr/bin/bash
  File: "/usr/bin/bash"
    ID: fd0000000000 Namelen: 255     Type: xfs
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 9330226    Free: 8128895    Available: 8128895
Inodes: Total: 18669568   Free: 18540126
[anliven@CentOS7 ~]$ 
[anliven@CentOS7 ~]$ stat -t /usr/bin/bash
/usr/bin/bash 960392 1880 81ed 0 0 fd00 5446 1 0 0 1512140401 1470153607 1492906124 0 4096
[anliven@CentOS7 ~]$ 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM