With Terminal: Size and Space Commands

Let's say we want to know the size of a file, folder or hard disk space on our server and we don't have a graphical interface. How do we do it?

See the size of files and folders with "du".

There are several ways to accomplish this. Let's look at some simple commands to run applications that are already installed, usually on all systems. If we want, for example, to know the size of an .iso or a specific folder, we can use du.

$ du -bsh /fichero_o_carpeta

Du has more options, but in this case I use these 3:

  • -b [–bytes]: Show in bytes.
  • -s [–summarize]: Show only the total size of each argument.
  • -h [–human-readable]: Prints sizes readable (eg, 1K, 234M, 2G)

See disk space with "df".

To see the space I always use the command «df»It seems to me that it is the most comfortable to read. Its use is very simple, we just have to put:

$ df -h

This will return the mounted partitions, the use of space in each one and what remains of the rest, and everything in an easy to read way.

how to
Related article:
How to kill processes easily

Other data with tree.

Related article:
Shutdown and restart using commands

Another very interesting command is «tree» or what is called in Spanish «tree»  We have to install it and if we use this command we would obtain very interesting results.

$ sudo aptitude install tree

and try these variants:

$ tree /directorio

$ tree -h /directorio

$ tree -dh /directorio