Skip to main content

To determine the size of a directory using the terminal, you can use the du (disk usage) command. The syntax for this command can vary slightly depending on the operating system you are using, but a common way to use it is as follows:

 

For Linux and macOS

du -sh /path/to/directory
du Disk usage
-s Summarise the total size of the directory and do not include the size of each individual file within the directory
-h Human-readable format, making the size easier to understand (e.g., displaying 1K for one kilobyte, 234M for 234 megabytes, etc.)
/path/to/directory Replace this with the path to the directory you want to check

This command will output the total size of the directory in a human-readable format.

Such as, to find the size of the files directory ~ /var/www/html/project/sites/default/, running the command du -sh files/ in UAT environment

15G    files/

Whereas, in the respective Production environment

23G    files/

 

Windows

To check the size of a directory named Documents in the current user's home directory, you would use:

du -sh ~/Documents

If you are using a Windows system, you would typically use PowerShell or the Command Prompt, and the command would be different. For example, in PowerShell, you can use:

Get-ChildItem -Path 'C:\path\to\directory' -Recurse | Measure-Object -Property Length -Sum

This command will give you the size in bytes. To convert it into a more readable format, you might need to do some additional calculations or formatting.

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...