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
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.
- 1Actually
-kgives results in kibibytes (but on macOS maybe it gives results in*bytesinstead of*bibytes)Edgar Magallon– Edgar Magallon2023-01-23 22:34:07 +00:00Commented 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.InTheWonderlandZoo– InTheWonderlandZoo2023-01-23 22:40:06 +00:00Commented Jan 23, 2023 at 22:40
- use
hinstead ofkwhich returns in human readable form likeKB,MB,GBetcRahul– Rahul2024-02-28 04:35:00 +00:00Commented Feb 28, 2024 at 4:35
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 total、 used 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!
- 1Thanks the last line did the trickdarmstadt beste– darmstadt beste2023-01-24 09:44:41 +00:00Commented Jan 24, 2023 at 9:44
- 1This is the wrong answer. Using
/YourDiskLocationwill show information about the file system that file or folder is on but not the size for just that file/folder.Akaisteph7– Akaisteph72024-07-09 13:26:02 +00:00Commented Jul 9, 2024 at 13:26