How to check directory size in Linux ubuntu centos

How to check directory size in Linux ubuntu centos

du command

Reference article: how to check directory size in Linux

Used to display the size of a directory or file.

  • Display the current directory file or file occupied space: du
  • Display the size of the specified file or folder: du test.txt
  • Check the space occupied by the directory in an easy-to-read format: du -h test
  • Show totals for current folder only: du -s *
  • View the space usage of the specified directory level in a convenient way: du -lh –max-depth=1

du command sorting

The command to view the size of the directory is du (of course, you can also view the file size), for example: du ems_data, is to view the size of each subdirectory under the ems_data directory; du, is to view the size of each subdirectory under the current directory; du *, is to view The size of each subdirectory and file in the current directory.

In order to improve the viewing effect, we need to sort the results, because the results of the du command are messy, for example:

  • Sort from largest to smallest: du ems_data | sort -nr
  • Sort by directory name: du ems_data | sort +1

The post Linux ubuntu centos how to view directory size first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/8909
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment