How to find the size of a file in Linux using the du command?

Published on Aug. 22, 2023, 12:17 p.m.

To find the size of a file in Linux using the du command, you can use the following command:

du -h file_name

Here, -h stands for “human-readable” and will display the file size in a human-readable format, such as KB or MB, rather than the default block size used by the du command.

For example, to find the size of a file named example.txt in your current directory, you can run:

du -h example.txt

This will output the size of the file in a human-readable format, such as “5.5K” or “2.1M”.

Note that the du command is typically used to find the sizes of directories and their contents, but it can also be used for individual files by specifying the file name as an argument. Additionally, the -h option may not be available on all versions of du.

Tags: