Linux Command for viewing disk properties, folder/file size-DF and Du

Source: Internet
Author: User
Tags disk usage

In Windows, you can easily view disk space, but you may be confused about how to view disk space in Linux. Don't worry. in Linux, you can use the following command to query logs.

  • UseDFCommand to view the disk attributes, including the file system type, disk size, used size, remaining size, usage percentage, and so on.
  • UseDuCommand to view the folder and file size.

 

The Command Parameter-H is used to make it easy for you to understand the size of each file. Without this parameter, the size of the displayed file is not K, M, G, and so on. Therefore, we recommend that you attach it each time.

 

View the remaining disk space:

[Root @ localhost ~] $ DF-H
Filesystem size used avai use % mounted on
/Dev/sda2 8.7 GB 2.9g 5.9g 33%/
/Dev/sda3 929g 621g 308G 67%/home

 

Of course, you may not care about the disk usage. You only need to know the size of a folder and use the du command.

 

View the size of a folder and all its subfolders:

[Root @ localhost ~] # Du -- Max-depth = 1-H
24 K./. gnome
8.0 K./. eggcups
8.0 K./. config
136 K./. gnome2
3.4 m./. Mozilla
......
272 K./. gconf
32 K./. mcop
16 K./. RedHat
1.7 m./. thumbnails
8.0 K./. gconfd
7.5 m.

 

 

 

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. 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.

 

 

If you only want to know the size of a folder and do not want to know the size of each subfolders, you can use the-S parameter.

 

View the size of a folder:

 

[Root @ localhost ~] # Du-SH

[Root @ localhost ~] # Du-h -- Max-depth = 0
7.5 m.

What I want to tell you is that the features of -- Max-depth = 0 are the same as those of-s.

 

 

 

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

 

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.