If you want to see how much space the disk has left, of course it is the DF command. [[email protected] ~]# df-h file system capacity already used% mount point available /de V/sda2 14g 11G 2.6G 82%/ /dev/sda1 &NBSP ; 99m 14M 81M 14%/boot tmpfs 442M 275M 168M 63%/dev/shm /dev/mapper/vg_test-lv_test 24m 1.3M 21M 6%/mnt/lvm [[email protected] ~] #当然你可能并不关系磁盘还剩余多少空间, you need To know the disk usage under the current folder: [[email protected] ~]# du--max-depth=1-h 24k ./.gnome Www.2cto.com & nbsp;8.0k ./.eggcups 8.0k ./.config 136k ./.gnome2 16k & nbsp:/.chewing 8.0k ./.gnome2_private 8.0k ./. trash 224k ./.gstreamer-0.10 28k /desktop 48k /.nautilus 48k /.metacity 240k & nbsp ./.scim 3.4m ./.mozilla 1012k ./.kde 12k ./.superkaramba 40K /.local 8.0k ./.qt 272k ./.gconf 32k /.mcop& nbsp;16k /.redhat 1.7m ./.thumbnails 8.0k ./.gconfd 7.5m . [[email protected] ~] #看上面使用了du the--max-depth=1-h command to find the disk usage, since it is not followed by the path, it defaults to the current path. The-h parameter of this command is to make it easy for you to read the size of each file, if there is no file size without this parameter k,m,g, etc. After executing the command, the previous n-1 line is the size of each folder in that directory. The last line shows the total size of the directory. Then you will say that you do not care about the size of each file in the directory, you just want to know the size of one of the files (folders), then there is no way? Of course you should remember, I have always stressed that the method is more than the problem, here is no exception. Take a look at the following example: [[email protected] ~]# du-sh 7.5m . www.2cto.com [[email protected] ~] #聪明的你一定发现了这里显示的大小和上面最后一行的大小是一样的. This means that the size shown here is the total size of the directory. I know your heart is sneer at, not method more than problem? There is only one answer to that. Of course, I won't let you down. Another way to compare soil, but still can solve the problem. [[Email&nbsP;protected] ~]# du-h--max-depth=0 7.5m . [[email protected] ~]# What I want to tell you is that the man handbook has been told: the--max-depth=0 function is the same as the-s function. Of course you can also use SED to print the last du-h--max-depth=1 line to solve the problem, but I don't recommend it. Here comes the principle of using commands to provide the original functionality of the option. If the command does not provide this functionality, then we need to use grep,sed,awk ourselves to pick the rows we need. Of course the du command can be followed by a file path to see the size of the specified path. [[email protected] ~]# du-sh/opt/oracle 5.6g /opt/oracle [[email protected] ~]# If the disk is too large, then look at the file size is more busy, please wait a while, hehe. [Turn] http://www.2cto.com/os/201207/142116.htmlhttp://www.cnblogs.com/longdouhzt/p/3177755.html
View disk space under Linux [go]