GoDaddy Help

Find areas of disk usage with SSH

The first step in investigating a disk usage issue is to find where the content is being consumed. This will allow you to remove unnecessary content (such as old backups) and make changes to prevent the issue from recurring. If you're comfortable using SSH on your server, you can find large files/directories and remove them over the command line.

Warning: If you don't know the purpose of a file or folder, don't remove it. Removing system files or directories is irreversible and may break the server (taking all of the sites down).
  1. Enable administrator access on your Gen 3 or Gen 4 server if you haven't already done so.
  2. Connect to my server with SSH (Secure Shell).
  3. Switch to the root user.
  4. For an overview of disk usage on the server, use the command df -h. In the example, you can see that 35G of our 40G server is in use.

    [root@server ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        909M     0  909M   0% /dev
    tmpfs           919M     0  919M   0% /dev/shm
    tmpfs           919M   17M  903M   2% /run
    tmpfs           919M     0  919M   0% /sys/fs/cgroup
    /dev/sda1        40G   35G  5.7G  86% /
    /dev/loop0      1.8G  2.9M  1.7G   1% /tmp
    tmpfs           184M     0  184M   0% /run/user/1000

Find large files

Oftentimes, there is a single large file or a few large files that are causing issues. You can find them by searching for files on the server that are over 500MB in size, and then to sort the list with the largest files listed at the end.

find / -type f -size +500M -exec du -h {} + 2>/dev/null | sort -h         

In our case, a large error_log file and some backup files were identified:

root@server ~]# find / -type f -size +500M -exec du -h {} + 2>/dev/null | sort -h 
5.1G    /home/onecool/public_html/wp-content/backups/coolexample_backup_1.tar.gz
5.1G    /home/onecool/public_html/wp-content/backups/coolexample_backup_2.tar.gz
11G     /home/onecool/public_html/error_log

Any large files can then be removed using the rm command, and confirmed by typing y (yes).

root@server ~]# rm /home/onecool/public_html/error_log
rm: remove regular file ‘/home/onecool/public_html/error_log’? y
[root@server ~]#

Find large directories

You can locate large directories (not just single files) by using variants of the du command. To list the sizes of the directories from the server root (sorted by size), you can use these commands:

  1. Change to the / directory
  2. root@server ~]# cd /
  3. Check the disk usage
  4. [root@server /]# du -sh *
  5. To list the 10 largest directories and sizes (including hidden directories) in the current directory, use this command:
  6. [root@server /]# du -sh .[!.]* * | sort -h | tail -10
  7. To find the the 10 largest directories on the entire server (not including subdirectories), you can use this command:
  8. [root@server /]# du -Sh / | sort -h | tail -10
Once you've identified a large directory, you can navigate to it, view it's contents, and remove any unneeded files.

Note: After clearing disk space, it's a good idea to reboot the server to make sure all needed services are properly restarted.

Next steps

  • Disk space issues can also be caused by inodes. After reviewing your disk space usage, move on to find inode usage.
  • It's important to identify and correct the root issue that caused the disk space to become exhausted. Move on to preventing disk usage issues.

More info

  • Our server experts can perform these steps for a fee. For more information about our Expert Services, please visit our Expert Service menu.

Share this article