Du command cheats
GuideThe du command is used to check the hard disk usage and calculate the disk space used by files, directories, and subdirectories. Different combinations of parameters can improve work efficiency faster. Only frequently used parameters are listed below. For more detailed information, use the man du command.1. Command Format
Du [Option] [file]
2. command functionsDisplays the disk space used by each file and directory.
3. Command ParametersDescription-a displays the size of all directories or files-B is measured in bytes, show the directory or file size-c show the total number of directories or files-k output in KB-m output in MB-s display only the total number of directories or files-h to K, M and G are used as the unit to improve information readability.-x skips the sizes of directories displayed in-S in different file system directories, but does not include the subdirectories. -D: displays the source file size of the specified symbolic link.InstanceInstance 1: displays the space occupied by directories or files.[Root @ tonyx home] # du4. /tonyxu /. mozilla/plugins4. /tonyxu /. mozilla/extensions12. /tonyxu /. mozilla4. /tonyxu /. gnome240. /tonyxu44. note: Only the size of the current home directory and subdirectory is displayed. The bottom 44 shows the total number of current directories.
Instance 2: displays the space occupied by the specified file[root@tonyx etc]# du inittab 4 inittab
Instance 3: view the space occupied by the specified directory[root@tonyx home]# du tonyxu4 tonyxu/.mozilla/plugins4 tonyxu/.mozilla/extensions12 tonyxu/.mozilla4 tonyxu/.gnome240 tonyxu
Example 4: Display files and directories[root@tonyx home]# du -ah tonyxu4.0K tonyxu/.mozilla/plugins4.0K tonyxu/.mozilla/extensions12K tonyxu/.mozilla4.0K tonyxu/.bash_history4.0K tonyxu/.gnome24.0K tonyxu/.viminfo4.0K tonyxu/.bash_profile4.0K tonyxu/.bash_logout4.0K tonyxu/.bashrc40K tonyxu
Instance 5: displays the disk space occupied by two directories.[root@tonyx tmp]# du yum yum.bake4 yum8 yum.bake
Instance 6: if a file in the var directory is too large, run the following command to view[Root @ tonyx tonyxu] # du-s/var/* | sort-nr468216/var/cache61260/var/lib1852/var/log1172/var/www160/var/spool148/var /run16/var/tmp16/var/lock8/var/empty8/var/db4/var/yp4/var/preserve4/var/opt4/var/nis4/var/local4/var /gdm4/var/games4/var/crash4/var/account0/var/mail description: sort-nr is arranged in reverse order from large to small. The files that occupy the largest disk space are first displayed and processed in a timely manner. Important commands in O & M should be kept in mind
Address: http://www.linuxprobe.com