Managing server resources effectively is crucial for maintaining optimal website performance. One of the most important aspects of server management involves monitoring inode usage and cache file sizes, especially on cPanel servers running LiteSpeed web server. This comprehensive guide will walk you through essential SSH commands to monitor and manage these resources.

What are INODEs?

Before diving into the commands, it’s important to understand what inodes are. An inode (index node) is a data structure that stores information about files and directories in Unix-like file systems. Each file and directory consumes one inode, making inode monitoring essential for server health, as hitting inode limits can prevent new file creation even when disk space is available.

Prerequisites

  • SSH access to your cPanel server
  • Basic command line knowledge
  • Root or user-level access to the directories you want to analyze

1. Viewing INODE Count in Readable Format

One of the most common tasks is checking how many files and directories exist in a specific location. Instead of getting overwhelming large numbers, you can format the output to show results in thousands (k format).

Command:

find /home/username/public_html | wc -l | awk '{print $1/1000 "k"}'

How it works:

  • find /home/username/public_html - Recursively lists all files and directories
  • wc -l - Counts the number of lines (which equals the number of files/directories)
  • awk '{print $1/1000 "k"}' - Divides the count by 1000 and adds ‘k’ suffix

Example output:

12.5k

This means there are approximately 12,500 files and directories in the specified path.

Pro tip:

Replace username with the actual cPanel username you want to check. You can also modify the path to check specific directories like /home/username/public_html/wp-content/uploads for WordPress upload folders.

2. Monitoring LiteSpeed Cache File Sizes

LiteSpeed cache can significantly improve website performance, but it’s important to monitor cache sizes to prevent them from consuming excessive disk space.

Command:

du -sh /home/*/lscache 2>/dev/null | sort -hr

How it works:

  • du -sh - Shows directory sizes in human-readable format (MB, GB, etc.)
  • /home/*/lscache - Checks lscache directories for all users
  • 2>/dev/null - Suppresses error messages for users without lscache directories
  • sort -hr - Sorts results by size in descending order (largest first)

Example output:

2.1G    /home/user1/lscache
890M    /home/user2/lscache
234M    /home/user3/lscache
45M     /home/user4/lscache

This output shows which accounts are using the most cache space, helping you identify accounts that might need cache optimization or cleanup.

3. Detailed INODE Analysis for Addon Domains

When managing multiple websites under a single cPanel account (addon domains), it’s crucial to understand which directories are consuming the most inodes. This detailed analysis helps identify problematic directories or websites.

Step-by-step process:

Step 1: Navigate to the user directory

cd /home/username

Step 2: Run the comprehensive inode analysis

echo "Detailed Inode usage for: $(pwd)" ; \
for d in $(find -maxdepth 1 -type d | cut -d/ -f2 | grep -xv . | sort); do \
  c=$(find $d | wc -l) ; printf "$c\t\t- $d\n" ; \
done ; \
printf "Total: \t\t$(find $(pwd) | wc -l)\n"

Understanding the command:

  • echo "Detailed Inode usage for: $(pwd)" - Shows current directory path
  • find -maxdepth 1 -type d - Finds only directories in current level
  • cut -d/ -f2 | grep -xv . - Processes directory names and excludes current directory
  • sort - Alphabetically sorts directory names
  • For each directory, it counts all files/subdirectories and displays the count
  • Finally shows total inode usage for the entire account

Example output:

Detailed Inode usage for: /home/erengg
1247		- mail
2856		- public_html
892		- tmp
3421		- www
156		- logs
Total: 		8572

This breakdown helps you identify which directories (websites) are using the most inodes, making it easier to optimize or clean up problematic areas.

Best Practices and Tips

Optimization Strategies

  1. Cache Management: Regularly clean old cache files that are no longer needed
  2. Log Rotation: Implement proper log rotation to prevent log files from consuming excessive inodes
  3. Temporary File Cleanup: Remove unnecessary temporary files and old backups
  4. Email Cleanup: Clean up old emails, especially in accounts with high email traffic

Troubleshooting Common Issues

  • If you see extremely high inode counts, check for:
    • Malware infections creating numerous small files
    • Runaway backup processes
    • Uncontrolled cache growth
    • Large email queues or spam folders

Advanced Usage

Checking Specific File Types

To count specific file types (e.g., images):

find /home/username/public_html -name "*.jpg" -o -name "*.png" -o -name "*.gif" | wc -l

Finding Large Directories

To find directories with the most files:

find /home/username/public_html -type d -exec sh -c 'echo "$(find "$1" -maxdepth 1 | wc -l) $1"' _ {} \; | sort -nr | head -10

Conclusion

Effective inode and cache management is essential for maintaining server performance and avoiding resource limitations. Regular monitoring using these SSH commands will help you:

  • Prevent inode limit issues before they occur
  • Optimize cache usage for better performance
  • Identify and resolve resource consumption problems quickly
  • Maintain better overall server health

Remember to always test these commands in a safe environment first, and consider automating regular checks through cron jobs for proactive server management.

By implementing these monitoring techniques, you’ll have better control over your cPanel server resources and can provide more reliable hosting services for your websites.