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 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


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   f3niX said

    I read this post 2 years later. 🙂

  2.   Leo said

    I read this post 3 years later xD

  3.   Juan Carlos said

    Excellent, practical and simple. thanks ..!!

  4.   Daniel said

    I read this post 4 years later xD

  5.   luisdelbar said

    I read this post 5 years later, but thanks xD

  6.   Ezekiel said

    It is already April 2016 and the post is still helping.

    thanks for the input.

  7.   Raul said

    Well, this post helped me, thank you. 15/05/2016

  8.   sergio said

    We are at 12/08/2016 and XD is still working

  9.   Mario Lara said

    I read this post on 18/08/2016 and you can't imagine how much it has helped me.

  10.   Francisco Martín said

    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

  11.   Noah Recra said

    I read this post on 01/09/2016

  12.   Abraham said

    05 / Sept / 2016 Thank you!

  13.   Gerard said

    I read this article 5 years later, on September 27, 2016.
    XDDD

  14.   John titor said

    I come from the future and the post still helps.
    05/11/2059

  15.   Ulan said

    4 days after the future of Jhon Titor and still useful. 9-11-2016. Salu2.

  16.   Pablo said

    I COME FROM THE PAST, WHAT IS THIS SERVING FOR?

  17.   Zentola said

    This post reminds me of timelessness, and the relative of space time.
    Open source is always useful. 😉 and with the friends of DesdeLinux and Let's UseLinux, more accessible.
    Be debian my friend

  18.   German said

    January 2017, thanks for the post! 🙂

  19.   Anselmo Gimeno said

    Great. And I see it now, February 2017.
    A greeting.

  20.   theury said

    27-02-2017 very useful

  21.   Mike_DCX said

    Help me: 09-05-2017

  22.   Michael said

    And the truth is that it continues to help !! Congratulations.

  23.   Anonymous said

    June 8, 2017 and continues to help.
    Thank you

  24.   diego said

    June 23, 2017… and will continue to help

  25.   Anonymous said

    June 29 and keep helping …… Thank you!

  26.   Jesus said

    Great, thank you helped me today. 325 BC

  27.   gabo said

    still works, still works !!! 17/07/2017

  28.   Anonymous said

    WOW

  29.   Anonymous said

    We are in the year 2032 and it still serves hahaha

  30.   dark end said

    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.

  31.   dark end said

    I tried it this way

    df -hT | grep sd

  32.   John Burgos said

    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

  33.   Anonymous said

    September, I like

  34.   Anonymous said

    September 27, 2017 ...

  35.   Anonymous said

    January 2147

  36.   Anonymous said

    great excellent information helped me a lot ... regards

  37.   Anonymous said

    19/10/2017 and keep helping

  38.   Carlos said

    21 - 10 - 2017 Thank you !!!

  39.   Carlos said

    i like papayas

  40.   pepper said

    vamos !!

  41.   Daniel Portugal Revilla said

    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.

  42.   Rolando said

    15-12-2017 Thank you very helpful brother, very good.

  43.   anRoswell said

    28-12-2017 Still helping, thank you men.

  44.   Mixterix said

    06-01-2018 and it served me on android with termux

  45.   Anonymous said

    He had some of the information, but not all. Still I was impressed, excellent post, thank you

  46.   Anonymous said

    I read this post 7 years later.

  47.   Anonymous said

    I read this post and she still doesn't love me: 'v

  48.   Anonymous said

    23/02/2018…. not to decline ...
    It still helps!

  49.   Anonymous said

    23/03/2018 Is this still standing?

    1.    Zentola said

      You visit us from the future !!!
      08/03/2018

  50.   Limber said

    25/03/2018 Still works!

    thanks!

  51.   shadowind30 said

    14/04/2018 And It Still Works

  52.   John Edison Castro Cubillos said

    «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

  53.   bpmircea said

    awesome, june 2o18 and the xd cheat still works

  54.   Mark1234s4 said

    2019 t

  55.   Archibaldo de la Cruz said

    21-02-2020 The post still helps. Thanks a lot.