Last active
February 27, 2025 17:09
-
-
Save ppcdias/a2bdd5ed5481a1d5074e56d120265f79 to your computer and use it in GitHub Desktop.
WHM/cPanel Useful Terminal Commands for Managing and Optimizing Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find the Largest Files in your Linux Home cPanel Directory | |
find /home -type f -exec du -h {} + | sort -rh | head -n 20 | |
# List All error_log Files | |
find /home/*/public_html -type f -name error_log -exec du -sh {} \; | |
# Clear All error_log Files | |
find /home/*/public_html -type f -iname error_log -delete | |
# Import a .sql File into a MySQL Database | |
mysql -u root -p dbname < /home/username/database.sql | |
# Get a List of the Most Frequent IP Addresses in Apache Logs | |
cat /usr/local/apache/logs/access_log | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 20 | |
# Execute a cPanel Backup Immediately | |
/usr/local/cpanel/bin/backup | |
# How to Restart the cPanel using the Command Prompt | |
service cpanel restart | |
# View disk usage of cPanel users' tmp folders | |
du -sh /home/*/tmp/ | |
# Remove all content from cPanel users' tmp folders | |
find /home/*/tmp/ -mindepth 1 -exec rm -rf {} + | |
# List All WordPress Backup Files (All-in-One WP Migration) | |
find /home -type f -path "*/ai1wm-backups/*.wpress" -exec du -h {} + | |
# Remove All WordPress Backup Files (All-in-One WP Migration) | |
find /home -path /home/virtfs -prune -o -type f -path "*/ai1wm-backups/*.wpress" -exec rm {} + | |
# List all cPanel user log files | |
find /home/*/logs -type f | |
# Remove all cPanel user log files | |
find /home/*/logs -type f -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment