Linux view the size of folders and files in the current directory

Source: Internet
Author: User
Tags disk usage

The file parameter is actually a directory that reports all the files in that directory. If the file parameter is not provided, the DU command uses the files in the current directory.

If the file parameter is a directory, then the number of reported blocks is the sum of the blocks allocated to the directory and to the directory itself.

Specify the-a flag to report the number of blocks in the individual file. The individual files specified by the file parameter are always listed, regardless of whether the-a flag is used or not.

Specifies the-s flag, which reports all blocks of all files in the specified file and directory.

The block count includes an indirect block for each file. The block count is calculated in 512-byte units, regardless of the cluster size used by the system. Specifies the-K flag, which calculates the number of blocks in 1024-byte units.

Cases:
To summarize disk usage for a directory tree and each of its subtrees, enter:
Du/home/fran
This shows the number of disk blocks in the/home/fran directory and each of its subdirectories.
To summarize disk usage for a directory tree and each of its subtrees with 1024-byte blocks, enter:
Du-k/home/fran
This shows the number of 1024-byte disk blocks in the/home/fran directory and each of its subdirectories.
To summarize disk usage for one directory tree and each of its subtrees through MB disk blocks, enter:
Du-m/home/fran
This shows the number of MB disk blocks (approximately the nearest second decimal number) in the/home/fran directory and each of its subdirectories.
To summarize the disk usage of one directory tree and each of its subtrees with GB blocks, enter:
Du-g/home/fran
This displays the number of GB disk blocks (approximately to the nearest second decimal number) in the/home/fran directory and each of its subdirectories.
To display each file disk usage, enter:
Du-a/home/fran
This shows the number of disk blocks contained in each file and in the subdirectory of the directory/home/fran. The number next to the directory is the disk usage of the directory tree. The number next to the regular file is the separate disk usage for that file.

To view file and folder sizes:
Du–sh dirname


If you look at the size of all files and files in a directory:

Du–sh *

For example:

Du-sh opt

Sort by file size

Du–sh * |sort–n

Linux view the size of folders and files in the current directory

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.