• 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

Delete Directory And Contents Recursively Without Prompt On Linux

Check User Login History In Ubuntu Linux Command Line

Use Locate Command To Find File In Linux Terminal By Name

How To Change Terminal Color In Ubuntu Command Line

How To Run Fsck Manually In Linux To Fix Unexpected Inconsistency

How To Fix Broken Packages On Ubuntu From Terminal

Re Execute The Previous Command In Linux Ubuntu Command Line

How Much RAM Is Needed For Ubuntu PC

How To Find Large Files And Directories In Linux Command Line

How To Use Clear Command History In Linux Terminal

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

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