1. stat命令: display file or file system status

[OPTIONS]
-L, --dereference: follow links
-f, --file-system: display file system status instead of file status
for example:
$stat -f /
File: "/"
ID: 226bbf67f89f2919 Namelen: 255     Type: ext2/ext3
Block size: 4096       Fundamental block size: 4096
Blocks: Total: 13166733   Free: 11754278   Available: 11085427
Inodes: Total: 3350528    Free: 3148391
$stat /usr/binzip
  File: "zip"
  Size: 192376     Blocks: 376        IO Block: 4096   普通文件
Device: 805h/2053d Inode: 394634      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2011-07-19 20:16:56.993522058 +0800
Modify: 2010-12-13 19:41:58.000000000 +0800
Change: 2011-06-04 09:13:15.072502606 +0800
 
2. df命令
df 是来自于coreutils 软件包,系统安装时,就自带的;我们通过这个命令可以查看磁盘的使用情况以及文件系统被挂载的位置。(如果后面参数是文件则是文件所在文件系统的信息,不能统计/查看单个文件或目录的情况)
luffy@luffy-laptop:~$ df -lh # df #Used without arguments, df reports on all mounted file systems.
文件系统            容量  已用  可用 已用%% 挂载点
/dev/sda5              51G  5.4G   43G  12% /
none                  968M  728K  968M   1% /dev
none                  976M  1.6M  974M   1% /dev/shm
none                  976M   96K  976M   1% /var/run
none                  976M     0  976M   0% /var/lock
选项简介:
  -h, --human-readable 以可读性较好的格式显示尺寸(例如:1K 234M 2G)
  -l, --local 只显示本机的文件系统
  -t, --type=类型 只显示指定文件系统为指定类型的信息
  -T, --print-type 显示文件系统类型
  -B, --block-size=大小 使用指定字节数的块
      --total 显示总计信息
  -i, --inodes 显示inode 信息而非块使用量
  -a, --all 包含虚拟文件系统
      --sync 取得使用量数据前先进行同步动作
例如:
luffy@luffy-laptop:~$ df -t ext4
luffy@luffy-laptop:~$ df /dev/sda5
文件系统           1K-块      已用      可用 已用% 挂载点
/dev/sda5             52666932   5619528  44372000  12% /
 
3. du - estimate file space usage
选项:
  -h, --human-readable 以可读性较好的方式显示尺寸(例如:1K 234M 2G)
  -c, --total 显示总计信息
  -a, --all 输出所有文件的磁盘用量,不仅仅是目录(默认是目录的磁盘用量)
  --apparent-size 显示表面用量,而并非是磁盘用量;虽然表面用量通常会
小一些,但有时它会因为稀疏文件间的"洞"、内部碎
片、非直接引用的块等原因而变大。
  -L, --dereference 找出任何符号链接指示的真正目的地
  -P, --no-dereference 不跟随任何符号链接(默认)
  -B, --block-size=大小 使用指定字节数的块
  -m 等于--block-size=1M
  -b --bytes
du -b myfile 等于 wc -c myfile
  -s, --summarize 只分别计算命令列中每个参数所占的总用量
例如:
luffy@luffy-laptop:~$ du -s -B G /home
2G /home
指定-s没有递归计算子目录的占用量。
      --max-depth=N 显示目录总计(与--all 一起使用计算文件)
当N 为指定数值时计算深度为N;
--max-depth=0 等于--summarize
例如:
luffy@luffy-laptop:/usr$ du -B M --max-depth 1 /usr
197M /usr/bin
183M /usr/src
187M /usr/lib32
2M /usr/local
34M /usr/sbin
24M /usr/include
1051M /usr/share
1074M /usr/lib
1M /usr/games
2748M /usr
The du user command gives the number of bytes/block-size contained in all files and recursively directories within each specified directory or file (filename). 
If filename is missing, `.' (the current directory) is used.  A file which 
has multiple links to it is only counted once. 
 
Used space plus available space is less than the amount of space in the file system (kilobytes) because the system reserves a fraction of the space in the file system to allow its allocation routines to work well. The amount reserved is  typically about 10%.  (This may be adjusted using the tunefs command.  Refer to  the man pages on tunefs(8) for more information.)  When all the space on a file  system, except for this reserve, is in use, only the super-user can allocate  new files and data blocks to existing files.  This, however, may cause the file  system to be over allocated.  When a file system is over allocated in this way,  df may report that the file system is more than 100% utilized. 
 
This section gives the technical explanation of why du and df sometimes report different totals of disk space usage. 
 
When a program that is running in the background writes to a file while the process is running, the file to which this process is writing is deleted. Running df and du shows a discrepancy in the amount of disk space usage.  The df command shows a higher value. 
 
When you open a file, you get a pointer.  Subsequent writes to this file references this file pointer.  The write call does not check to see if the file 
is there or not.  It just writes to the specified number of characters starting at a predetermined location.  Regardless of whether the file exist or not, disk blocks are used by the write operation. 
 
The df command reports the number of disk blocks used while du goes through the file structure and and reports the number of blocks used by each directory.  As far as du is concerned, the file used by the process does not exist, so it does not report blocks used by this phantom file.  But df keeps track of disk blocks used, and it reports the blocks used by this phantom file.
 
4. fdisk 是一款强大的磁盘操作工具,fdisk -l相当与df,来自util-linux软件包,这里不作介绍了。
 
reference:
Linux 查看磁盘分区、文件系统、使用情况的命令和相关工具介绍 http://www.linuxsir.org/main/?q=node/41
du 与df区别 http://www.chinaunix.net/jh/6/465673.html
man du df stat