##stat命令
stat filepath
xanarry@ThinkPad:/$ stat ~/Downloads/jdk-8u60-linux-x64.tar.gz
File: '/home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz'
Size: 181238643 Blocks: 353984 IO Block: 4096 regular file
Device: 808h/2056d Inode: 261742 Links: 1
Access: (0666/-rw-rw-rw-) Uid: ( 1000/ xanarry) Gid: ( 1000/ xanarry)
Access: 2017-02-01 17:36:43.177892508 +0800
Modify: 2015-10-02 12:43:29.853291000 +0800
Change: 2016-12-26 23:33:34.619480450 +0800
Birth: -
##wc命令wc -c filename 参数-c表示统计字符, 因为一个字符一个字节, 所以这样得到字节数
xanarry@ThinkPad:/$ wc -c ~/Downloads/jdk-8u60-linux-x64.tar.gz
181238643 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
##du命令du -b filepath 参数-b表示以字节计数
xanarry@ThinkPad:/$ du -b ~/Downloads/jdk-8u60-linux-x64.tar.gz
181238643 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
或者du -h filepath 直接得出人好识别的文件大小
xanarry@ThinkPad:/$ du -h ~/Downloads/jdk-8u60-linux-x64.tar.gz
173M /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
如果对一个目录执行du,du会递归列出目录中的所有文件,并显示其大小,同时也会显示目录中所有文件的大小。假如我们想知道一个目录下所有文件占用空间的总大小,执行:du 目标目录 -sh
# -s, --summarize display only a total for each argument
# -h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)
##ls命令ls -l filepath 第五列为文件字节数
xanarry@ThinkPad:/$ ls -l ~/Downloads/jdk-8u60-linux-x64.tar.gz
-rw-rw-rw- 1 xanarry xanarry 181238643 10月 2 2015 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
ls -h filepath h表示human, 加-h参数得到人好读的文件大小xanarry@ThinkPad:/$ ls -lh ~/Downloads/jdk-8u60-linux-x64.tar.gz
-rw-rw-rw- 1 xanarry xanarry 173M 10月 2 2015 /home/xanarry/Downloads/jdk-8u60-linux-x64.tar.gz
原文链接:https://blog.csdn.net/xiongyangg/article/details/54809810