View the size of the specified folder and file under Linux

Source: Internet
Author: User
Tags file size file system readable sort disk usage

DF Command: View the available space and usage of all current file systems

DF can view the level of folder size, usage ratio, file system and its mount point, but there is nothing for the file

The code is as follows:

Df-lh

Parameter-H indicates the use of "human-readable" output, that is, in the file system size using GB, MB, and other readable format.

The first field (filesystem) and the last field (mounted on) of the command output above are the file system and its mount point respectively. We can see/dev/sda1 this partition is hanging in the root directory.

The next four fields size, Used, avail, and use% are the capacity of the partition, the size used, the remaining size, and the percentage used

Du command: Querying the disk usage space of a file or folder

If you have a large number of files and folders in the current directory, you can iterate through the space used by all files and folders by using commands with no parameters du. This is a bad place to see if it's too big, so you have to specify the number of layers in the Drill-down directory, Parameters: –max-depth=, which is a very useful parameter! as follows, note that you can use "*" to get the size of the file's usage space.

The code is as follows:

[Root@bsso yayu]# du-h–max-depth=1 work/testing

27M Work/testing/logs

35M work/testing

[Root@bsso yayu]# du-h–max-depth=1 work/testing/*

8.0K work/testing/func.php

27M Work/testing/logs

8.1M Work/testing/nohup.out

8.0K work/testing/testing_c.php

12K work/testing/testing_func_reg.php

8.0K work/testing/testing_get.php

8.0K work/testing/testing_g.php

8.0K work/testing/var.php

[Root@bsso yayu]# du-h–max-depth=1 work/testing/logs/

27M work/testing/logs/

[Root@bsso yayu]# du-h–max-depth=1 work/testing/logs/*

24K Work/testing/logs/errdate.log_show.log

8.0K Work/testing/logs/pertime_show.log

27M Work/testing/logs/show.log

View the size of the Linux file directory and the number of files contained in the folder

The code is as follows:

Du-sh xmldb/Statistic Total size

DU-SM * | Sort-n//Statistics current directory size and size sort

Du-sk * | Sort-n

Du-sk * | grep GUOJF//Look at the size of a person

du-m | Cut-d "/"-F 2//Look at the text before the second/character

See how many files there are in this folder/*/*/* how many files

The code is as follows:

Du xmldb/

Du xmldb/*/*/* |wc-l

The difference between Du and DF

Du statistics File size added

DF Statistic block Usage

If there is a process opening a large file, the large file is directly out of RM or MV, then du will update the statistics, DF will not update the statistics, or think the space is not released. Until the process of opening a large file is killed.

This way, when the files below/var/spool/clientmqueue are deleted regularly, the space is not released unless the process is killed.

The system recovers after the process is killed using the following command.

Fuser-u/var/spool/clientmqueue

ls command: View file size in K, M, G

The code is as follows:

Ls

Ls-l

Ls-lh

Ll-h

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.