Running low on disk space can affect your website’s performance. To resolve this, it is important to identify which files or directories are consuming the most space. cPanel’s built-in terminal offers a quick and efficient way to locate and manage large files.
This guide walks you through the process systematically.
Follow the process:
- Log in to cPanel.
- Scroll to the “Advanced” section and click on “Terminal” to access the built-in CLI.
- Navigate to the Correct Directory:
- The Terminal opens in your user’s home directory by default. To ensure you are in the correct location, type:
cd ~
- Press Enter to move to the home directory.
- To work with website files, navigate to the public_html directory by typing:
cd ~/public_html/
- The Terminal opens in your user’s home directory by default. To ensure you are in the correct location, type:
- Locate Large Files:
- Use the following command to find files larger than 100MB:
find . -type f -size +100M -exec du -h {} \; | sort -rh | head -n 10
- Command Breakdown:
- find . – Searches from the current directory.
- -type f – Limits the search to files only.
- -size +100M – Targets files larger than 100MB (adjust as needed).
- -exec du -h {} \; – Displays file sizes in a readable format (e.g., MB, GB).
- sort -rh – Sorts results by size (largest first).
- head -n 10 – Shows the top 10 largest files.
- Use the following command to find files larger than 100MB:
- Review Results:
The Terminal displays the largest files and their sizes. Use this data to decide which files to keep, move, or delete. - Identify Large Directories
- To find the largest directories instead of individual files, run:
du -h --max-depth=1 | sort -rh | head -n 10
- –max-depth=1 – Limits the search to one directory level. Adjust this value (e.g., –max-depth=2) to include subdirectories.
- To find the largest directories instead of individual files, run:
- Delete Unnecessary Files:
If you want to delete a file, use:rm filename
Warning: Always double-check before deleting files to avoid accidentally removing critical data.
Using the Terminal in cPanel is a straightforward and efficient way to locate large files and manage your disk space. Regular maintenance ensures optimal performance and prevents storage-related issues.
For additional support, seek assistance from our support staff.