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 [–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.
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
56 comments, leave yours
I read this post 2 years later. 🙂
I read this post 3 years later xD
Excellent, practical and simple. thanks ..!!
I read this post 4 years later xD
I read this post 5 years later, but thanks xD
It is already April 2016 and the post is still helping.
thanks for the input.
Well, this post helped me, thank you. 15/05/2016
We are at 12/08/2016 and XD is still working
I read this post on 18/08/2016 and you can't imagine how much it has helped me.
Very useful post!
As a complement: If you run df -hT, with the T, you can see the type of filesystem for each mount point: ext4, xfs, etc.
df-hT
Seen in: http://www.sysadmit.com/2016/08/linux-ver-espacio-en-disco.html
I read this post on 01/09/2016
05 / Sept / 2016 Thank you!
I read this article 5 years later, on September 27, 2016.
XDDD
I come from the future and the post still helps.
05/11/2059
4 days after the future of Jhon Titor and still useful. 9-11-2016. Salu2.
I COME FROM THE PAST, WHAT IS THIS SERVING FOR?
This post reminds me of timelessness, and the relative of space time.
Open source is always useful. 😉 and with friends from DesdeLinux and UsemosLinux, more accessible.
Be debian my friend
January 2017, thanks for the post! 🙂
Great. And I see it now, February 2017.
A greeting.
27-02-2017 very useful
Help me: 09-05-2017
And the truth is that it continues to help !! Congratulations.
June 8, 2017 and continues to help.
Thank you
June 23, 2017… and will continue to help
June 29 and keep helping …… Thank you!
Great, thank you helped me today. 325 BC
still works, still works !!! 17/07/2017
WOW
We are in the year 2032 and it still serves hahaha
I read this post in March 2017 and today I have tried it but filtering the result with grep
df -hT | grep sd
where sd is the hard drive or hard drives that we have installed.
I tried it this way
df -hT | grep sd
Very interesting post. To add, it is possible to sort the output of du -h (which shows the result in MB, GB,…) by passing the output to the sort -h command. With the -h of sort you can sort the output of du -h by size.
More info and examples: http://www.sysadmit.com/2017/09/linux-saber-tamano-directorio.html
September, I like
September 27, 2017 ...
January 2147
great excellent information helped me a lot ... regards
19/10/2017 and keep helping
21 - 10 - 2017 Thank you !!!
i like papayas
vamos !!
still serves!!! 10/12/2017 almost Christmas!
It worked for me: I have CentOS minimal installed on a 5GB virtual disk, and I have several packages installed to deploy node.js applications.
15-12-2017 Thank you very helpful brother, very good.
28-12-2017 Still helping, thank you men.
06-01-2018 and it served me on android with termux
He had some of the information, but not all. Still I was impressed, excellent post, thank you
I read this post 7 years later.
I read this post and she still doesn't love me: 'v
23/02/2018…. not to decline ...
It still helps!
23/03/2018 Is this still standing?
You visit us from the future !!!
08/03/2018
25/03/2018 Still works!
thanks!
14/04/2018 And It Still Works
«Update 2018/05»
Required arguments for long options are also required
for short options.
-a, –all include dummy file systems
-B, –block-size = SIZE scale sizes by SIZE before printing them; eg
–Direct show statistics for a file instead of mount point
–Total produces grand total
-h, –human-readable print sizes in human readable format (eg, 1K 234M 2G)
-H, –si likewise, but use powers of 1000 not 1024
-i, –inodes display node-i information instead of using blocks
-k as –block-size = 1K
-l, –local limits the listing to local filesystems
–No-sync does not call sync before getting how to use
–Output [= FIELD_LIST] uses the output format defined by
-P, –portability uses POSIX format for output
–Sync calls sync before getting how to use
-t, –type = TYPE restricts the listing to file systems of type TYPE
-T, –print-type shows the type of the filesystem
-x, –exclude-type = TYPE restricts the listing to filesystems that are not of type TYPE
-v (has no effect)
–Help displays this help and ends
–Version reports the version and exits
awesome, june 2o18 and the xd cheat still works
2019 t
21-02-2020 The post still helps. Thanks a lot.