• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How to Get Directory Size in Linux Command Line

How to Get Directory Size in Linux Command Line

By Sourabh / December 24, 2024 Category: How To, Ubuntu

Here is the Linux/Unix command to check folder size in GB. This post explains how to check disk space by folder on Linux Ubuntu Systems.

Method 1: The ls Command

The ls command can be used to find the size of a directory in Linux. Here are some examples of the ls command:

  1. ls -l : Displays a list of files and directories in long format, including their sizes in bytes.
  2. ls -h : Scales file and directory sizes into KB, MB, GB, or TB if the size is larger than 1024 bytes.
  3. ls -lh : Displays details about the file and its size in a readable format.
  4. ls -lhR : Displays all files in the directory, along with their sizes and a total for all files.

Note: for a more accurate result, you can use the du or tree utilities.

  1. du: This command displays the disk space usage of files and directories.
  2. tree: This command displays a visual representation of directories.

Method 2: The du Command

The du command in Linux stands for “disk usage” and is used to estimate and summarize the disk space used by files and directories. It provides a way to check the size of directories and the files contained within them.

Commonly Used Options of du command are:

-h, --human-readable: Print sizes in human-readable format (e.g., KB, MB, GB).
-s, --summarize: Show only the total size of each argument.
-a, --all: Write counts for all files, not just directories.
-c, --total: Produce a grand total.
-d N, --max-depth=N: Limit the depth of directory traversal.
-m: Show sizes in megabytes.
-k: Show sizes in kilobytes.


Method 3: The tree Command

The tree command in Linux displays the directory structure of a given path in a tree-like format. It can show files and directories with hierarchical indentation – using colors and shows the connection between the subdirectories and files with lines.

If tree is not already installed on your system, you can install it using the command “sudo apt-get install tree”. Once installed it can be used to get directory and files information.

The basic syntax of the tree command is “tree”.

For more details and available options for the tree command you can use the Linux manual command “man tree”.

I hope you find this article useful.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap