Created
April 13, 2016 15:47
-
-
Save patrickgill/790c85f73c02b48727dfdf8f42946c60 to your computer and use it in GitHub Desktop.
disk usage information on a Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df – displays disk usage information based on file system (ie: entire drives, attached media, etc) | |
At the command prompt, type: | |
df -h | |
The -h flag is for ‘human readable form’ meaning return results in the familiar megabyte/gigabyte format. You should see something like this: | |
$ df -h | |
Filesystem Size Used Avail Use% Mounted on | |
/dev/disk0s2 74G 52G 22G 70% / | |
In this case, /dev/disk0s2 is the main hard disk, and 70% of it is in use. | |
du – displays disk usage information for each file and directory (ie: home directories, folders, etc) | |
At the command prompt type: | |
du -sh ~ | |
The -s flag is for a summary, and once again the -h flag is for ‘human readable form’, the ~ is your home directory. You should see something like this: | |
$ du -sh ~ | |
26G /Users/MacUser | |
This users home directory takes up 26gb of space! | |
Another example, type | |
du -sh * | |
at the terminal. The * wildcard will cover all files in your home directory or whatever directory you are currently in, by default the Terminal will launch with your home directory as the pwd (present working directory). | |
$ du -sh * | |
32M Desktop | |
217M Documents | |
531M Downloads | |
12G Library | |
5.2G Movies | |
2.1G Music | |
1.5G Pictures | |
8.0k Public | |
36k Sites | |
As you can see, the * allows for a breakdown of the space taken up by which directory. This can be extremely useful when trying to clear up disk space if you don’t know what is hogging all the room. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment