0

In this tip, we are going to see how to use the Terminal under Ubuntu to calculate the size of a folder. The size will be expressed in megabytes.

Get Started


Launch the terminal (Ctrl+Alt+T) and run this command to calculate the size of a folder:

du -sh folder

Replace "folder" with the name of the folder you want to calculate its size. If, for example, you want to calculate the size of your home folder, then use this command:

du -sh /home

Here are the outputs I got:

~$ du -sh /home
981M /home

My home folder has currently a size of 981 MB.

To know the size of folders and files stored in a folder, then use this command:

du -sh /home *


To display the size of all files, folders and sub-folders stored inside a folder, then use this command:

du -h /home *

To display the size of a specific file extension, then use this command:

du -sh /home *.txt


Replace .txt with any file extension of your choice.


That's it!

Post a Comment

 
Top