Linux du and df commands

Source: Internet
Author: User

In linux, the du and df commands also asked me about the command for viewing the directory size in Linux. Now I have learned the commands du/df a while ago. A while ago, some sub-Tests encountered that the program could not be executed due to the full disk space. Therefore, df and du commands were used. View the directory size at www.2cto.com du, and view the disk usage by df. Commands that I often use (if necessary, sudo uses the root permission), 1. view the size of a directory: du-hs/home/master/logs ents view the size of all directories in the directory in descending order of size: sudo du-sm/etc/* | sort-nr | less 2. view disk usage (File System usage): sudo df-h df -- block-size = GB-h makes the output more readable; du-s only displays the total usage of directories (not the subdirectories ), -m Displays the directory size in MB (of course-k/-g is KB/GB ). For more information, see man du and man df. Www.2cto.com du-estimate file space usage Summarize disk usage of each FILE, recursively for directories. df-report file system disk space usage Show information about the file system on which each FILE resides, or all file systems by default. df displays the amount of disk space available on the file system containing each file nameargument. if no file name is given, the space available on al L currently mounted file systems is shown. the description of du is disk usage, which indicates disk space usage. The function is to enter each subdirectory of a specified directory step by step and display the usage of data blocks in the file system occupied by this directory, if no directory is specified, the current directory is counted. The meaning of each option of the command www.2cto.com du is as follows: a: displays the disk space occupied by each file in all directories and the second directory. s: Only displays the total size of each file. B: the size is represented by bytes x: Skipping directories on different file systems does not count a: recursively displaying the number of data blocks occupied by each file in the specified directory and its children's directories... use du to view root @ tech163:/home/htmlfile # du 16. /test 60. /bbb 84. the first column is the disk space capacity in blocks, and the second column lists the directory names that use these spaces in the directory. 1) Check the size of the subdirectories in the current directory. root @ tech163: /home/htmlfile # du-sm. 1. du-sm.. "indicates the current directory. 2) Check the size of the current directory and subdirectory. root @ tech163:/home/htmlfile # du-h 16 K. /test 60 K. /bbb 84 K. -h indicates the use of K, M, G humanized display. 3) view the size of the bbb directory in the current directory, but do not want to view other directories and subdirectories root @ tech163: /home/htmlfile # du-ch bbb | tail-n 1 60 K total uses the pipeline containing the du and tail commands.-c indicates calculating the total size of the listed directories. 4) list the sizes of all directories and files in the current directory. root @ tech163:/home/htmlfile # du-ah bbb 4.0 K bbb/mysql. php 4.0 K bbb/index.htm 4.0 K bbb/p. php 28 K bbb/memcache. php 12 K bbb /. session. php. swp 4.0 K bbb/hello.html 60 K bbb, where-a indicates that the directory and file are included. 5) do not wrap the information to list the Directory and the subdirectory size. root @ tech163: /home/htmlfile # du-0 h 16 K. /test60K. /bbb84K. root @ tech163:/home/htmlfile # Where-0 indicates listing information without line breaks, and then outputting the second information. The difference between df and du is that du is a file-oriented command that only calculates the space occupied by files. Do not calculate the space occupied by the file system metadata. Df is calculated based on the file system population. No space is allocated in the file system to determine the size of allocated space in the system. The df command can obtain the space occupied by the hard disk and the remaining space. It can also display the I node and disk block usage of all file systems. The meaning of each option of the df command is as follows: a: displays all the file systems and disk usage of each partition I: displays the I-nodes usage k: size is represented by k (default) t: displays the disk usage of all partitions in a file system x: displays the disk usage of all partitions not in a file system T: display the file system name of each partition .... use df to view Filesystem 1K-blocks Used Available Use % Mounted on/dev/cciss/c0d0p1 2068156 611572 1351528 32%/tmpfs 1038080 4 1038076 1%/lib/init/rw udev 10240 64 10176 1%/ dev tmpfs 1038080 4 1038076 1%/dev/shm/dev/cciss/c0d0p9 130700120 44034236 8666588 4 34%/home/dev/cciss/c0d0p7 2068156 68932 1999224 4%/tmp/dev/cciss/c0d0p8 4132372 1760620 2161840 45%/usr/dev/cciss/c0d0p6 2068156 330104 1632996 17%/var the first line is the hard disk partition corresponding to the file system. The second line is the data block contained in the partition (1 Database is 1024 bytes) the fourth row is the array of used and unused data blocks. The fifth row is the percentage of space used by common users. The sixth row is the installation point of the file system. The third and fourth rows are not equal to the sum of used and unused data blocks. total data blocks in the second row, this is because the partition leaves a small amount of space for the system administrator to use. 1) chenyz @ gzhouse :~ $ Df-h file system capacity in use % available mount point/dev/cciss/c0d0p1 2.0G 598 M 1.3G 32%/tmpfs 1014 M 4.0 K 1014 M 1%/lib/init/ rw udev 10 M 64 K 10 M 1%/dev tmpfs 1014 M 4.0 K 1014 M 1%/dev/shm/dev/cciss/c0d0p9 125G 42G 83G 34%/home/dev /cciss/c0d0p7 2.0G 68 M 2.0G 4%/tmp/dev/cciss/c0d0p8 4.0G 1.7G 2.1G 45%/usr/dev/cciss/c0d0p6 2.0G 333 M 1.6G 18%/var where-h indicates K, m, G humanized display. Www.2cto.com 2) chenyz @ gzhouse :~ $ Df-ia file system Inode (I) used (I) available (I) % mount point/dev/cciss/c0d0p1 262752 60150 202602/tmpfs 23% 10 224142 224132/lib/init/rw proc 0 0 0-/proc sysfs 0 0 0-/sys procbususb 0 0 0-/proc/bus/usb udev 224142 770 223372 1%/dev tmpfs 224142 3 224139 1%/dev/shm devpts 0 0 0-/dev/pts/dev/cciss /c0d0p9 130763968 1972907 128791061 2%/home/dev/cciss/c0d0p7 262752 54 262698 1%/tmp/dev/cciss/c0d0p8 524832 35743 489089 7%/usr/dev/cciss/c0d0p6 262752 4896 257856 2%/var the so-called inode is used to store the basic information of files and directories, including time, file name, user and group. When dividing a sector, the system will first make a bunch of inode for later use. The number of inode is related to the total number of files and directories that can be created in the system. If most of the files to be stored are small, there will be a large number of files in hard disks of the same size, that is, a large number of inode are required to mount files and directories.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.