2

I want to see the current available disk space as well as how much the folder I am in is using. Is there some du/df command that not only tells me the size of my folder but also how much is still available in this directory ?

2 Answers 2

4

You can get the size of the disk usage of the current folder with the du command, using the "s" (summarize) option:

du -sk . 

The "k" signifies the result is in kibibytes (i.e. 1024 bytes).

To get the capacity of the disk partition that this directory resides, then you can use the df command:

df -k . 

This command returns the capacity of the whole disk partition, not specifically this directory.

Again the results are in kibibytes, so it will be more easily comparable to the result from the du command.

3
  • 1
    Actually -k gives results in kibibytes (but on macOS maybe it gives results in *bytes instead of *bibytes) Commented Jan 23, 2023 at 22:34
  • 2
    @EdgarMagallon - agreed we have all one time or another cursed disk vendors for usurping the word kilobyte. I have updated my answer to state kibibytes instead of kilobytes. Commented Jan 23, 2023 at 22:40
  • use h instead of k which returns in human readable form like KB, MB, GB etc Commented Feb 28, 2024 at 4:35
2

I think using df -h /YourDiskLocation will resolve your problem, and here's an example of df command:

$ df -h Filesystem Size Used Avail Use% Mounted on /dev/root 29G 11G 17G 39% / devtmpfs 325M 0 325M 0% /dev tmpfs 455M 0 455M 0% /dev/shm tmpfs 182M 1.3M 181M 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock /dev/mmcblk0p1 253M 31M 222M 13% /boot tmpfs 91M 20K 91M 1% /run/user/1000 

And on 2nd to 4rd column, there shows totalused and available size, and for example you want to see the home directory usage, like this:

$ df -h /home Filesystem Size Used Avail Use% Mounted on /dev/root 29G 11G 17G 39% / 

From the above information, /home is mounted on /, and 11G is used, 17G available. And you can check this answers too:

Determine what device a directory is located on

Hope that helped you, and hope your understand my poor English!

2
  • 1
    Thanks the last line did the trick Commented Jan 24, 2023 at 9:44
  • 1
    This is the wrong answer. Using /YourDiskLocation will show information about the file system that file or folder is on but not the size for just that file/folder. Commented Jul 9, 2024 at 13:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.