Checking size of files/folders in Ubuntu

To see the size of the current folder in Ubuntu, you can use the du (disk usage) command. Here's how to do it:


1. Command to See the Size of the Current Folder

Navigate to the folder you want to analyze, then run:

du -sh
  • -s: Summarize the total size of the directory.

  • -h: Human-readable format (e.g., KB, MB, GB).

This will display the total size of the current folder.


2. See the Sizes of All Subdirectories

To list the sizes of all subdirectories along with the total size of the current folder, use:

du -h --max-depth=1
  • --max-depth=1: Limits the output to the sizes of the current folder and its immediate subdirectories.

Output example:

4.0K    ./subdir1
8.0K    ./subdir2
12K     .

Here:

  • subdir1 is 4 KB.

  • subdir2 is 8 KB.

  • . represents the total size of the current folder.


3. Sort Subdirectories by Size

If you want to see all subdirectory sizes sorted by size, you can combine du with sort:

This will list directories in ascending order of size.


4. Analyze Hidden Files and Directories

To include hidden files and directories, use:

  • -a: Displays the size of all files and directories, including hidden ones.


5. Graphical Method

If you prefer a graphical interface:

  1. Open Files (File Manager).

  2. Right-click the folder and select Properties.

  3. The folder size will be displayed in the Size section.

Let me know if you want to explore more commands for disk usage analysis!

Last updated