Getting folder size with CLI

This command shows the list of sub-folders of the current folder with their size:

du -h --max-depth=1

This command shows the list of sub-folders of a specific folder with their size:

du -h --max-depth=1 /var

To get the disk size, run this command:

df -h

To remember between df and du, here is a tip:

  • df: Disk Free
  • du: Disk Usage

Sometimes you see the outputs of these commands are different. One situation that I usually see is I get the disk full notification, while du tells me I have some GB to use.

After looking for a while, I notice that it's the Apache issue. Apache keeps its log in the memory, and that makes the df fails. Restarting Apache fixes the bug:

service apache2 restart

This solution is provided in StackOverflow.

One important thing to remember is when you see disk is full, try to remove Apache's log first (in /var/log/apache2). It usually takes up to GB!

🔥 HOT: Interested in boosting your WordPress SEO? My Slim SEO plugin is a super lighweight and automated plugin that handles most the hard work for you: meta tags, sitemap, redirection, schema & link building.

👉 Have a look and you will love it: wpslimseo.com

PS: we'll drop lifetime pricing from Dec 01, 2024. Get it now before it's gone!

Leave a Reply

Your email address will not be published. Required fields are marked *


Copyright © 2024 Deluxe Blog Tips. All rights reserved.

My products: Meta Box | Slim SEO