Run the "du" command to view the file size in Linux.

Source: Internet
Author: User

In Linux, run the "du" command to view the file size and display the number of file blocks. 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 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.

View File Size syntax in Linux
Du [-a |-s] [-k] [-m] [-g] [-l] [-r] [-x] [-H |-L] [file...]

Specify the-a flag to report 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.
Specifies the-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 the-k flag and calculate 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 du cannot get the file attribute or cannot read the directory, it reports an error and affects the exit status of the command. View the file size mark in Linux

-A 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 calculates the number of blocks in 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 counts the size of the file or File hierarchy referenced by the link.
-K calculates the number of blocks in 1024 bytes instead of 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 should count the size of the file or File hierarchy referenced by the link.
-M calculates the number of blocks in MB 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.
-R: indicates the name of an inaccessible file or directory. This is the default setting.
-S displays the usage of the entire disk for all specified files, or displays the total disk usage for all files in a directory. Compare the flag with the-a flag.
-X only evaluates files that reside on the same device as the files or directories specified by the File parameter when the File size is large. For example, you can specify a directory that contains files on multiple devices. In this case,
The-x mark shows the block size for all files that reside on the same device as the directory.

If all-k,-m, and-g are specified, or any two of them are specified, the last one takes effect. The usage of the flags-m and-g output disks is approximately the nearest second decimal number.

Exit status

In Linux, the command for viewing the file size returns the following export values:

0 ends successfully.

Edit recommendations]

  1. Linux traffic monitoring software tool series
  2. Linux network traffic monitoring tool installation and functions
  3. Basic implementation and usage of Linux Traffic Control
  4. How to view Linux Nic traffic and Its Features
  5. Linux Network Traffic Security Management Method

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.