2.13.2015

du / df commands in linux



1. df
df command can get how much space is occupied and  how much availabe space is left, it cal also display the usage information for both inode and disk blocks.
df options:
-a: show all file system disk usage
-k: display output in K bytes
-i: display inode infomation
-t:Display disk space usage for each of the specified type of  File system
-T: display file system type

Sample outputs:
Display Each File System Disk Space Usage
[root@devops ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda1            20641404   1165572  18427308   6% /
tmpfs                   250416         0    250416   0% /dev/shm
/dev/xvdb1            10317828   2392496   7401216  25% /media/
  • The first column of Filesystem is the device file path name of file system  (usually the hard disk partitions);
  • The second column of Inodes is the amount of inode of data block.
  • The third and fourth  columns are the amount of used and available data block number.you may feel strange, why the total block number for third and fourth columns is not equal to the amount in the second column. because each partition left little space for the system administrator  by default. Even the ordinary user space is full, there are still have spaces so that administrator can login to solve the problem.
Show Inode Ssage For Each File System
[root@devops ~]# df -ia
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/xvda1           1310720   26718 1284002    3% /
proc                       0       0       0    -  /proc
sysfs                      0       0       0    -  /sys
devpts                     0       0       0    -  /dev/pts
tmpfs                  62604       1   62603    1% /dev/shm
xenfs                      0       0       0    -  /proc/xen
Show File System Type
[root@devops ~]# df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/xvda1    ext3    20641404   1165580  18427300   6% /
tmpfs        tmpfs      250416         0    250416   0% /dev/shm
/dev/xvdb1    ext3    10317828   2392612   7401100  25% /media

2. du
du is the abbreviation of “disk usage”, this command will progressively into each subdirectory of the specified directory and display how many blocks were occupied. If not given a specified directory, then will show the statistics of the current directory.
du options:
-a:write counts for all files, not just directories
-s: display only a total for each argument
-b: display output in bytes( the default is K)
-k: display output in K bytes
-c: produce a grand total
-l: count sizes many times if hard linked

Sample output:
Check The Disk Space Usage For /mnt Directory
[root@devops ~]# du -abk /mnt
4       /mnt
Display The Disk Space Usage Of Each Directory(do not include FILE)
[root@devops boot]# du
252     ./efi/EFI/redhat
256     ./efi/EFI
260     ./efi
288     ./grub
19804   .
Display The Disk Usage For  All Of File And Directory(pass -a option) and display output in bytes(pass -b option)
[root@devops]# du -ab /boot/
166     /boot/.vmlinuz-2.6.32-279.el6.x86_64.hmac
13057907        /boot/initramfs-2.6.32-279.el6.x86_64.img
3986608 /boot/vmlinuz-2.6.32-279.el6.x86_64
179157  /boot/symvers-2.6.32-279.el6.x86_64.gz
101820  /boot/config-2.6.32-279.el6.x86_64
249106  /boot/efi/EFI/redhat/grub.efi
253202  /boot/efi/EFI/redhat
257298  /boot/efi/EFI
261394  /boot/efi
2341856 /boot/System.map-2.6.32-279.el6.x86_64
64      /boot/grub/device.map
11364   /boot/grub/vstafs_stage1_5

0 comments:

Post a Comment