If your website is running out of disk space, it's important to identify which files or directories are consuming the most space. cPanel provides an easy way to locate large files by using the built-in Terminal feature. Follow the steps below to quickly find and manage large files using the command line interface (CLI) within your cPanel hosting account.
Prerequisites:
- Access to your cPanel account.
- A basic understanding of command-line operations.
Step-by-Step Guide:
-
Log in to cPanel
Open your web browser and log in to your cPanel account. You can access this via your customer service portal login at https://encode.host/login then look for the "Login to cPanel" link within your dashboard.
-
Access the Terminal
Once logged in, scroll down to the Advanced section. Click on Terminal to open the built-in command-line interface. If this is your first time using it, you might receive a warning. Click Proceed to access the Terminal.
-
Navigate to the Home Directory
By default, the Terminal opens in your user's home directory, but you can always ensure you're in the correct location by typing:
cd ~which will "change directory" to your home "~"Press Enter to execute the command. This will take you to the home directory of your cPanel account, where most of your files and folders are stored. If you want to work with your website files, then are stored in the public_html directory which you can access with
cd ~/public_html/. -
Finding Large Files
To find large files, we'll use the
findcommand combined withdu(disk usage) to list files above a certain size threshold. You can adjust this threshold to suit your needs.Run the following command to find files larger than 100MB:
find . -type f -size +100M -exec du -h {} \; | sort -rh | head -n 10Explanation of the command:
find .- Starts searching from the current directory (.).-type f- Tellsfindto look for files (not directories).-size +100M- Finds files larger than 100MB (you can adjust the size, e.g.+50Mfor 50MB).-exec du -h {} \;- For each file found, runsdu(disk usage) to display the file size in a human-readable format (e.g., KB, MB, GB).sort -rh- Sorts the output by size in reverse order (largest files first).head -n 10- Limits the output to the top 10 largest files.
-
Review the Results
The results will show the largest files in your cPanel account, along with their sizes. You can use this information to decide whether to keep, move, or delete these files.
-
Additional Tips
If you want to find the largest directories instead of individual files, you can use the following command:
du -h --max-depth=1 | sort -rh | head -n 10This will list the top 10 directories taking up the most space within the current directory, sorted by size.
You can also adjust the depth of the search by changing the value of
--max-depth. For example,--max-depth=2will look two levels deep into subdirectories. -
Deleting Large Files
If you decide to delete any large files, you can do so by running the following command:
rm filenameWarning: Be cautious when deleting files. Ensure that you're not removing any critical files that your website depends on.
Conclusion
By using the built-in Terminal in cPanel, you can easily locate large files and manage your disk usage more effectively. Regularly checking and managing your large files helps optimise your web hosting account and prevent issues related to disk space.
If you need further assistance with your Encode hosting account, feel free to contact our support team.