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?
Table of Contents
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 [–sumarize]: 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.
Other data with tree.
Another very interesting command is «tree»Or what is being in Spanish« tree »😀 We have to install it and if we use this command we will obtain very interesting results.
$ sudo aptitude install tree
and try these variants:
$ tree /directorio
$ tree -h /directorio
$ tree -dh /directorio