View disk space in linux

Source: Internet
Author: User
To check how much space is left on the disk, use the df command. [Root @ localhost ~] # Df-H file system capacity in use % available mount point/dev/sda214G11G2.6G82 % // dev/sda1. .. info & nbsp; |
To check how much space is left on the disk, use the df command. [Root @ localhost ~] # Df-h file system capacity in use % available mount point/dev/sda2 14G 11G 2.6G 82%/dev/sda1 99 M 14 M 81 M 14%/boot tmpfs 442 M 275 M 168 M 63%/dev/shm/dev/mapper/vg_test-lv_test 24 M 1.3 M 21 M 6%/mnt/lvm [root @ localhost ~] # Of course, you may not be concerned with the amount of space remaining on the disk. you need to know the disk usage in the current folder: [root @ localhost ~] # Du -- max-depth = 1-h 24 K. /. gnome www.2cto.com 8.0 K. /. eggcups 8.0 K. /. config 136 K. /. gnome2 16 K. /. chewing 8.0 K. /. gnome2_private 8.0 K. /. trash 224 K. /. gstreamer-0.10 28 K. /Desktop 48 K. /. nautilus 48 K. /. metacity 240 K. /. scim 3.4 M. /. mozilla 1012 K. /. kde 12 K. /. superkaramba 40 K. /. local 8.0 K. /. qt 272 K. /. gconf 32 K. /. mcop 16 K. /. redhat 1.7 M. /. thumbnails 8.0 K. /. gconfd 7.5 M. [root @ localhost ~] # Check that the command du -- max-depth = 1-h is used to find the disk usage. because there is no following path, it is the current path by default. The-h parameter of this command is used to make it easy for you to understand the size of each file. without this parameter, the file size is not k, M, G, and so on. After the command is executed, n-1-1 line shows the size of each folder in the directory. The last line shows the total size of the Directory. Then you will say that you don't care about the size of each file in the directory. you just want to know the size of one of the files (folders). Is there a solution? Of course, you should remember that I have always stressed that there are always more methods than problems, and this is no exception here. See the following example: [root @ localhost ~] # Du-sh 7.5 M. www.2cto.com [root @ localhost ~] # Clever, you must have found that the size shown here is the same as the size of the last line above. This means that the displayed size is the total size of the Directory. I know that you are sneering in your heart, isn't there more ways than problems? There is only one answer here. Of course, I won't disappoint you. Another method is relatively good, but it can still solve the problem. [Root @ localhost ~] # Du-h -- max-depth = 0 7.5 M. [root @ localhost ~] # What I want to tell you is that the features of -- max-depth = 0 are the same as those of-s. Of course, you can use sed to print the last line of du-h -- max-depth = 1 to solve the problem, but I do not recommend it. This involves a principle. try to use the command to provide the original function of the option. If the command does not provide this function, we need to use grep, sed, and awk to select the required line. Of course, the du command can be followed by the file path to view the size of the specified path. [Root @ localhost ~] # Du-sh/opt/oracle 5.6G/opt/oracle [root @ localhost ~] # If the disk is too large, it will be too busy to check the file size. please wait for a while. Author tl_oni
Related Article

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.