I needed to find out the size of a directory while connected to my Ubuntu server. When I used the properties menu in Windows explorer however, that data was not populated so I needed an alternative – the terminal. It turns out that using the terminal to find the directory size is incredibly easy.
The basic syntax for finding the directory size in Linux is goes like this:
du [options] /path/to/directory
du --help if you want more.
du -h– formats sizes according to kilo, mega, and gigabytes.
du -hc– produces a line with the word total at the end
du -hcs– skips displaying size for sub-directories.
That’s all there is to finding the size of a directory in Linux.