cPanel : useful shell commands for web developers

cPanel offers a lovely graphical interface for managing your files and databases, but sometimes it lacks the flexibility and power to answer all of your problems. Many cPanel hosts can provide you with SSH access to your account. SSH offers a secure terminal session, also called a Command Line Interface (CLI), giving you access to a broad range of linux commands. Although this environment can appear daunting at first, you can solve many common problems with one-liners – a single line of code – from the command prompt.

Here are some examples of useful shell commands for cPanel that can make life much easier when you’re in a pinch.

File management one-liners

Find all PHP error_log entries

If you are not displaying PHP errors to the screen (and for security reasons you shouldn’t) then finding the cause of the error can be a bit tedious. This one-liner will find all error_log files, extract just the entries for today, aggregate and show them in chronological order. Just run it from the root directory of your website (usually the public_html directory):

Find the largest files

This will show the top 10 largest files under the current directory.

Find number of files in each directory

CMS caching out of control? Accidentally copied a huge number of files somewhere? This script will count the number of files in each directory and give you a sorted list.

Apache log analysis

If you need to analyse some issues right away, before your daily web stats are updated, then here are a few quick and dirty tricks to find out who’s bombarding your website with requests. Of course you could download your log files and analyse them on your PC, but it can save a lot of time to do a quick check while logged into the command line. From your home directory (e.g. /home/username) try these following commands. Just replace yourdomain below with the domain of the website you want to analyse.

Find the number of requests per IP address

Find the most popular URLs requested



No comments yet.

Leave a Reply

Time limit is exhausted. Please reload CAPTCHA.