Disk Usage
The du command allows you to see how space a directory is using. If you wish to know how much disk space you are using in your home directory or any directory, please follow the commands below:
- ssh to a Linux machine such as openlab.ics.uci.edu using any SSH client
- cd to the directory you wish to check. For example,
cd /home/username
- Run a du command to find your disk usage and direct the output to a file:
nice -n 19 du -ks * > /tmp/put_file_name_here
- You can sort that file to display contents in a readable format.
- The following sort will print out the size in kilobytes in the 1st column, megabytes in the 2nd column, and the file name in the 3rd column.
sort -rn /tmp/put_file_name_here | awk '{print $1 "KB\t", $1 / 1024 "MB\t", $2 }'
- All 'dot' files and 'dot' folders are skipped in the above process. Dot files and dot folders are preceded by a period and are hidden by default.
- To view them, type:
ls -la
- To check the disk usage for them, type:
du -ks .??* > /tmp/put_file_name_here