Usage of du command parameters in linux (1)

Source: Internet
Author: User

This article describes in detail the usage of the du command parameters in linux, and further describes its usage using examples.

Du-sh * view the folder size in the current directory

Du command

Purpose

This topic describes how to use a disk.

Syntax

Du [

-

|

-S

] [

-K

] [

-M

] [

-G

] [

-L

] [

-R

] [

-X

] [

-H

|

-L

] [File...]

Description

In linux, the "du" command shows the number of blocks used for files. If the specified File parameter is actually a directory, all files in the directory should be reported. If the File parameter is not provided, the du command in linux uses the files in the current directory.

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

Specify

-

Indicates the number of blocks in the individual file. Whether or not the-a flag is used, the individual files specified by the File parameter are always listed.

Specify

-S

Flag. The report is used for all blocks of all files in the specified file and directory.

The block count includes the indirect blocks of each file. The block count is calculated in 512 bytes and is irrelevant to the cluster size used by the system. Specify

-K

The number of blocks in 1024 bytes.

Note:

Files with multiple links are counted and written only for one entry.

Because the block count is only based on the file size, unallocated blocks are not included in the number of reported blocks.

If the du command in linux does not obtain the file attribute or cannot read the directory, it reports an error and affects the exit status of the command.

Flag

-

Displays the disk usage for each specified file or the disk usage for each file in the directory. Compare the flag with the-s flag.

-G

The number of blocks is calculated in the unit of GB, instead of the default 512 bytes. The output value of disk usage should be a floating point number, because if bytes are used, the value will be very large.

-H

If a symbolic link is specified in the command line, the du command in linux calculates the size of the file or File hierarchy referenced by the link.

-K

The number of blocks is calculated in 1024 bytes, rather than the default 512 bytes.

-L

Evenly allocate blocks between file links and multiple links. Based on the default value, files with two or more links are counted only once.

-L

If you have specified a symbolic link in the command line or encounter a symbolic link multiple times during File hierarchy traversal, The du command in linux should count the size of the file or File hierarchy referenced by the link.


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.