Hongmu Notes
Home Summary of pitfalls In the Linux terminal, view the sizes of all files and subdirectories in the current directory and display them sorted by size.
Summary of pitfalls

In the Linux terminal, view the sizes of all files and subdirectories in the current directory and display them sorted by size.

In the Linux terminal, view the sizes of all files and subdirectories in the current directory and display them sorted by size.

In a Linux terminal, to display the size of all files and subdirectories in the current directory, sorted by size, use the following common commands:

1. Display the size of all files/directories (including hidden files) and sort them.

du -sh .[!.]* * 2>/dev/null | sort -hr
  • du -sh: Calculate the size of each file (-s for summary, -h for human-readable format)

  • .[!.]* *Match hidden files (excluding ); .  ; ..) and non-hidden files

  • 2>/dev/nullIgnore error messages (e.g., when no matches are found)

  • sort -hrSort by size in descending order

2. Displays only non-hidden files and directories within the current directory (most commonly used)

du -sh * | sort -hr

3. Display the top-level subdirectories and the total size of the current directory (depth 1)

du -h --max-depth=1 | sort -hr

4. List only regular files (does not display directories)

find . -maxdepth 1 -type f -exec ls -lh {} \; | sort -k5 -hr

5. Use; ls View file size (excluding total directory size)

ls -lhS

 

  • -l  Details,-h readable,-S Sort by file size in descending order (the directory shows approximately 4 KB – this is approximate)

recommendDaily use; du -sh * | sort -hr The most intuitive approach.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Browser caching increases the speed of secondary visits to your website

Browser caching increases the speed of secondary visits to your website Summary of pitfalls

Use browser caching of official words: If users will visit your website multiple times, browser caching of static resources can save users time. Cache headers should be applied to all cacheable static resources, not just to a small subset of static resources (for example, images). Cacheable resources include JS and CSS files, image files, and other binary object files (media files, PDF files, etc.). Normally, HTML doesn’t…
👁 202

Recommended reading

(Adaptive mobile version) Red Internet Technology News Website – PBootCMS Template; Responsive Article/Blog Website Source Code Download – 0586

(Adaptive mobile version) Red Internet Technology News Website – PBootCMS Template; Responsive Article/Blog Website Source Code Download – 0586 Practical Collection pbootcms Template

A red PbootCMS responsive blog website template for internet technology news, compatible with both PC and WAP devices. The design features an energetic information-feed style, making it ideal for technology blogs and IT news websites to share industry updates. This template helps technology media outlets attract online readers and build their influence. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 42
(Adaptive Mobile Version) Law Firm PBootCMS Website Template – Download Responsive Legal Consultation Website Source Code – 0347

(Adaptive Mobile Version) Law Firm PBootCMS Website Template – Download Responsive Legal Consultation Website Source Code – 0347 Practical Collection pbootcms Template

This adaptive mobile-friendly PbootCMS responsive website template is designed for law firms and legal consultation services to showcase their legal expertise, successful case studies, and team profiles. It helps legal service providers establish an authoritative online presence and attract clients. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 55
(PC+WAP) Blue Atmospheric Infrastructure Construction Project – Construction Industry PbootCMS Website Template; Download Source Code for Infrastructure Facility Project Company Websites – 0107

(PC+WAP) Blue Atmospheric Infrastructure Construction Project – Construction Industry PbootCMS Website Template; Download Source Code for Infrastructure Facility Project Company Websites – 0107 Practical Collection pbootcms Template

This PbootCMS template features a sophisticated blue color scheme, making it ideal for infrastructure construction projects and construction-related enterprises; it supports both PC and WAP devices. Its robust, professional design effectively showcases infrastructure projects, engineering case studies, and corporate strength, helping construction or infrastructure companies establish an authoritative online presence. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin...
👁 69
Logo image management of Imperial cms website is convenient for subsequent uploading and replacement (use of image information management and PHP call).

Logo image management of Imperial cms website is convenient for subsequent uploading and replacement (use of image information management and PHP call). Program Notes Empire cms

It is inconvenient to use extended variables to manage imperial pictures. Therefore, you can use the empire's own plug-in: picture information management. Usage, as shown above, but more introduction! Here is the calling method! & lt; div class=" logo fl w_img" & gt; & lt; ? php $img=$empire-& gt; fetch1(" SELECT * FROM…
👁 388
Marketing-oriented outdoor advertising equipment website template 1122

Marketing-oriented outdoor advertising equipment website template 1122 Practical Collection Yiyou template

This EyouCMS template is designed for the marketing-oriented outdoor advertising equipment industry, featuring a tech-driven marketing style that effectively showcases outdoor advertising products, technical solutions, project cases, and brand strength. It enables advertising equipment companies to present their products online and attract advertising agencies as well as brand clients. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Questions Regarding EyouCMS Installation...
👁 60
js click the button to pop up the query...the query results will be displayed after three seconds

js click the button to pop up the query...the query results will be displayed after three seconds Language Notes JavaScript

After clicking the button, a box pops up, showing that the payment status is being checked.... After three seconds, it prompts that the payment bill has not been found, please pay. The main logic is like this. As for the code that can be added to the backend request in the middle, it is omitted here. The html code is: <button data-v-b863db80="" type="button" class="el-button b…
👁 168