Linux disk space view command (du, df) remaining space view details

Check the usage df of the hard disk, the -h unit is displayed according to the size, the -m unit is M, check the file size du of the specified directory, check the total size of the current directory, check the respective sizes of the subdirectories under the current directory, and specify the directory to check the size For example, specify to see the img directory

1. View the usage of the hard disk df


-h unit is displayed according to the size, -m unit is M

$df -h
file system type capacity used available used% mount point
/dev/sda6 ext4 9.4G 4.0G 5.0G 45% /
udev devtmpfs 2.0G 4.0K 2.0G 1% /dev
tmpfs tmpfs 784M 956K 783M 1% /run
none tmpfs 5.0M 0 5.0M 0% /run/lock
none tmpfs 2.0G 1.7M 2.0 G 1% /run/shm
/dev/sda5 ext4 983M 43M 891M 5% /boot
/dev/sda8 ext4 55G 29G 23G 56% /home


2. Check the file size of the specified directory du


Check the total size of the current directory

$du -sh
417M 2015-01-21 14:22 .
417M 2015-01-21 14:22 Total usage


Check the size of subdirectories under the current directory

$du -h
6.8M 2014-02-28 10:53 ./img/taobao
18M 2014-04-02 11:23 ./img
30M 2015-01-22 17:43 ./work
417M 2015-01-22 17:43
.417M 2015-01-22 17:43 Total usage


Specify size of the directory to view, such as specifying the img directory

$du -h img
6.8M 2014-02-28 10:53 img/taobao
18M 2014-04-02 11:23 img
18M 2014-04-02 11:23 Total usage


View specified file size

$du -h img/1.jpg
200K 2014-04- 01 11:50 img/1.jpg
200K 2014-04-01 11:50 Total usage


3. If the above example does not meet your needs, you can see the detailed explanation of the following command:


du usage:

$du --help
usage :du [options]... [files]...
 or :du [options]... --files0-from=F
Calculate the disk usage for each file, and the total usage for the directory.

Parameters that are required for long options are also required for short options.
  -a, --all print disk usage for all files, not just directories
      --apparent-size show apparent usage, not disk usage; although apparent usage is usually
smaller , it can sometimes be "holes", internal
fragmentation , non-directly referenced blocks, etc.
  -B, --block-size=size in blocks using the specified number of bytes. For example -BM
displays the size in 1,048,576 bytes. See SIZE format. -b, --bytes equal to --apparent-size --block-size=1
  -c, --total display total information
  -D, --dereference-args dereference symlinks listed on the command line
      --files0-from =F Calculate the disk space occupied by NUL-terminated file names in file F
If the value of F is "-", read the file name from standard input
  -H is equal to --dereference-args (-D)
  -h, - -human-readable display size in a more readable way (eg: 1K 234M 2G)
      --si like -h, but use base 1000 instead of 1024 for calculations
  -k is equal to --block-size=1K
  - l, --count-links If it is a hard link, calculate its size multiple times
  -m is equal to --block-size=1M
  -L, --dereference find out the real destination indicated by any symlink
  -P, --no-dereference do not follow any symlink (default)
  -0, --null treat each empty line as 0 bytes instead of newline
  -S, --separate-dirs exclude subdirectory usage
  -s, --summarize only calculate the total usage of each parameter in the command line separately
  -x, --one-file-system skip at directories on different filesystems
  -X, --exclude-from=files exclude files matching the pattern described in the specified file
      --exclude=PATTERN exclude files matching the pattern described in PATTERN
      --max-depth=N Display the total of the directory (used with --all to calculate the file)
when N is the specified value, the calculation depth is N;
--max-depth=0 is equal to --summarize
      --time Display the last of all files in the directory or subdirectories of the directory Modification time
      --time=WORD Display WORD time instead of modification time:
atime, access, use, ctime or status
      --time-style=style display the time according to the specified style (the style interpretation rules are the same as the "date" command):
full- iso, long-iso, iso, +FORMAT
      --help display this help message and exit
      --version display version information and

exit The value displayed is
the first available SIZE unit from the --block-size, DU_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables.
Otherwise, the default unit is 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE can be an optional integer followed by one of the following units:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and G, T, P, E, Z, Y.


df usage:

$df --help
usage: df [options]...[files]...
Display information about the file system where each file is located. The default is to display all file systems.

Parameters that are required for long options are also required for short options.
  -a, --all include virtual filesystem
  -B, --block-size=size in blocks using the specified number of bytes. For example -BM displays the size in 1,248,576
bytes. See SIZE format. --total display total information
  -h, --human-readable display size in more readable format (eg: 1K 234M 2G)
  -H, --si use 1000 as base instead of 1024 for calculation
  -i, - -inodes show inode information instead of block usage
  -k ie --block-size=1K
  -l, --local only display the local file system
      --no-sync do not synchronize before getting usage data (default)
  -P, --portability use POSIX compatible output format
      --sync before getting usage data Synchronize action first
  -t, --type=type only displays the information that the specified file system is of the specified type
  -T, --print-type displays the file system type
  -x, --exclude-type=type only displays the file system that is not specified type info
  -v (ignore)
      --help show this help and exit
      --version show version info and

exit The value shown is from
the first available SIZE from the --block-size, DF_BLOCK_SIZE, BLOCK_SIZE, and BLOCKSIZE environment variables unit.
Otherwise, the default unit is 1024 bytes (or 512 if POSIXLY_CORRECT is set).

SIZE can be an optional integer followed by one of the following units:
KB 1000, K 1024, MB 1000*1000, M 1024*1024, and G, T, P, E, Z, Y

from: http: //my.oschina.net/liting/blog/392051

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326657953&siteId=291194637