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:
- ls -l : Displays a list of files and directories in long format, including their sizes in bytes.
- ls -h : Scales file and directory sizes into KB, MB, GB, or TB if the size is larger than 1024 bytes.
- ls -lh : Displays details about the file and its size in a readable format.
- 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.
- du: This command displays the disk space usage of files and directories.
- 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.