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:

  1. ssh to a Linux machine such as openlab.ics.uci.edu using any SSH client
  2. cd to the directory you wish to check. For example,
    • cd /home/username
  3. 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
  4. 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 }'
  5. 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
accounts/check_disk_space.txt · Last modified: 2016/02/02 15:00 by dutran
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0