Complete website in Rs. 5,000 with Free Hosting & Domain. Offer ends in  00:00:00
Back to Blog

How to Check Disk Usage on VPS Hosting

Learn how to efficiently check disk usage on your VPS with our comprehensive guide. Discover essential commands and tools to identify and manage storage consumption, ensuring optimal server performance.

Jun 16, 2024 Updated: Jun 16, 2024

Is your VPS running out of storage space? Keeping an eye on disk usage is crucial for maintaining optimal performance and avoiding unexpected issues. In this guide, we’ll show you how to check what is using storage on your VPS, helping you manage your server more efficiently.

Why Monitoring Disk Usage is Important

Regularly monitoring disk usage on your VPS ensures you:

  • Prevent Downtime: Avoid service interruptions caused by running out of disk space.
  • Optimize Performance: Ensure your applications run smoothly by keeping sufficient free space.
  • Identify Issues Early: Spot unusual disk usage patterns that might indicate problems such as log file growth or unwanted files.

Steps to Check Disk Usage on Your VPS

Here are some effective methods to check disk usage on your VPS:

1. Connect to Your VPS

First, you need to connect to your VPS via SSH. Open a terminal and run the following command, replacing username and hostname with your actual credentials:

ssh username@hostname

2. Check Overall Disk Usage

Use the du (disk usage) command to see how much space each directory is using. Start by checking the root directory:

sudo du -h --max-depth=1 /

This command provides a human-readable (-h flag) summary of disk usage for top-level directories (--max-depth=1).

3. Drill Down into Specific Directories

Identify any large directories from the output and explore them further. For instance, if /var is using a lot of space, check its subdirectories:

sudo du -h --max-depth=1 /var

Continue this process to narrow down the space usage.

4. Use ncdu for Interactive Disk Usage Analysis

For a more interactive approach, use ncdu (NCurses Disk Usage). Install it with:

sudo apt-get install ncdu

Then run ncdu on the root directory or any specific directory:

sudo ncdu /

ncdu opens an interactive interface that lets you navigate through directories and view their sizes easily.

5. Check Specific File Types

If you suspect certain file types (like log files) are consuming a lot of space, search for them specifically. For example, to find large log files:

sudo find / -type f -name "*.log" -exec du -h {} + | sort -rh | head -n 10

This command finds all .log files, calculates their sizes, sorts them by size, and displays the top 10 largest ones.

Conclusion

Regularly checking disk usage on your VPS is vital for maintaining a healthy and efficient server environment. By following the steps outlined in this guide, you can easily identify which files and directories are consuming the most space and take appropriate action.

If you found this guide helpful, share it with others and check out our other posts for more tips on managing your VPS. Happy server managing!

Contact

Got A Question For Us?

Feel free to ask anything directly on call or fill the form and we will contact back within few hours.