Results 1 to 7 of 7

Thread: whats the terminal command line to see how much harddrive space you have left?

  1. #1
    Join Date
    Oct 2008
    Location
    San Gabriel Valley, CA
    Beans
    249
    Distro
    Ubuntu 18.04 Bionic Beaver

    whats the terminal command line to see how much harddrive space you have left?

    just curious

  2. #2
    Join Date
    May 2008
    Beans
    Hidden!

    Re: whats the terminal command line to see how much harddrive space you have left?

    Code:
    df
    The -h option makes it much more readable:

    Code:
    df -h
    And I personally use a little alias to trim the output a bit:

    Code:
    alias disk='df -h | grep -e /dev/sd -e Filesystem'
    Last edited by snova; March 11th, 2009 at 03:15 AM.

  3. #3
    Join Date
    Jan 2008
    Beans
    61

    Re: whats the terminal command line to see how much harddrive space you have left?

    Quote Originally Posted by snova View Post

    And I personally use a little alias to trim the output a bit:

    Code:
    alias disk='df -h | grep -e /dev/sd -e Filesystem'
    What does this command do??? I used it but I'm not sure what I just did.

  4. #4
    Join Date
    May 2008
    Beans
    Hidden!

    Re: whats the terminal command line to see how much harddrive space you have left?

    Quote Originally Posted by blackstripes View Post
    What does this command do??? I used it but I'm not sure what I just did.
    As it is, it won't do anything, only create an alias. It's so that you can type 'disk' and have the string on the right be executed in place.

    The command in question will run 'df -h', which prints filesystem information in a more readable fashion and pipe it to grep, which will print lines matching either '/dev/sd' or 'Filesystem'.

    The former matches block devices (i.e. your actual disk partitions, thus hiding all the virtual filesystems that don't actually take up space) and the latter matches the table header, just for completeness.

    The alias will only last until you close the terminal however, unless you append it to your ~/.bashrc file.

  5. #5
    Join Date
    Jan 2008
    Beans
    61

    Re: whats the terminal command line to see how much harddrive space you have left?

    Quote Originally Posted by snova View Post
    As it is, it won't do anything, only create an alias. It's so that you can type 'disk' and have the string on the right be executed in place.

    The command in question will run 'df -h', which prints filesystem information in a more readable fashion and pipe it to grep, which will print lines matching either '/dev/sd' or 'Filesystem'.

    The former matches block devices (i.e. your actual disk partitions, thus hiding all the virtual filesystems that don't actually take up space) and the latter matches the table header, just for completeness.

    The alias will only last until you close the terminal however, unless you append it to your ~/.bashrc file.
    Interesting. I have not used the alias command before; thanks for the description.

  6. #6
    Join Date
    Aug 2007
    Beans
    690

    Re: whats the terminal command line to see how much harddrive space you have left?

    du -sh

    is pretty handy for getting sizes of directories and files

    du -sh /home

    for example

  7. #7
    Join Date
    Jan 2009
    Location
    Canada
    Beans
    Hidden!

    Re: whats the terminal command line to see how much harddrive space you have left?

    2 things

    1: If you don't know what something does, it's usually better to find out what it does before you run it (not to say anyone has given you bad info on this thread). A so you know what is happening and B so you can change the command to your needs if it isn't just right.

    2: man pages are your friend
    "Always be wary of any helpful item that weighs less than its operating manual." - Terry Pratchett

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •