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