Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of viewing file and directory size by Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces you to Linux view file and directory size method, the content is very detailed, interested friends can refer to reference, hope to be helpful to everyone.

After using df command in Linux system, you can view the relevant situation of directory, but df has no effect on file, you can use du to view the relevant properties of file.

application scenarios

1. Perform file operations and encounter No space left on device. You can understand the overall layout by looking at the disk file size. 2. Check the file size before moving and transferring files to determine whether there is enough space available.

df command usage

df -T

df -T View mount directory

df -T Display Diagram

df -h

df -h View mount directory

df -h display

The parameter-h indicates output using "Human-readable", displaying output in human-readable formats such as GB, MB, etc. Unlike-T (T upper case), the file system type is not displayed, and the mount directory size is more readable.

Therefore, it is better to use df -Th in combination to view the size of the mount directory, as shown in the figure.

df -Th display

du command usage

du Common parameters

-h: Display in a human-readable manner (GB, MB)

-a: Displays the disk space occupied by directories, and also displays the disk space occupied by directories and files under them.

-s: Displays the disk space occupied by directories, not their subdirectories and files

-c: Display the disk space occupied by several directories or files, and also count their sum

Apparent-size: Displays the size of the directory or file itself

-l: Counts the size of disk space occupied by hard links

-L: Counts the amount of disk space occupied by the file to which the symbolic link points

cd location directory

du -sh View the total capacity of the current directory. The capacity occupied by each sub-item is not listed separately.

du -sh * View the capacity of files and subdirectories in the current directory (capacity occupied by each subitem).

du -sh * |sort -n Statistics the size of files and subdirectories in the current directory, and sorts them by-n (size).

About Linux view file and directory size method to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report