Before procedding to execute any command, log in to your Server with root credentials.
#1. Check Consumed and Available Disk Space
- Type the below command to display the information of your server's disk space.
# df -h
#2. Find and Sort Top Disk Abusers
Now, here comes the diagnostics part. The first step you should take to solve the disk space issue is to find out who’s consuming top disk space. This can be done easily by following the below command.
- Navigate to the home directory by using the cd /home command and then execute the following command.
du -sh * | sort -hr | head -n 40
*You can modify the number 40 as per your choice.- Now, execute the below given command to sort top disk abusers.
du -sh * | sort -hr | head -n 4 > /root/abusers.txt
- You can use the cat command to view the result (the list of abusers). Once you find the top abusers, the next step you should take is to find the highest space-consuming files in every abuser account.
#3. Find the Highest Space Consuming Files
- You can list the highest space consuming files and take action on them by using the below commands:
find /home/cp_username/ -type f -exec du -h {} + | sort -hr | head -100
*Replace cp_username with the cPanel account name which you find as an abuser.- List of all the files consuming more that allotted quota will appear. You can copy the path of the files and send it to the owner of the account with an alert.
#4. Delete Trash Files For All Users
- Use the below command to delete trash files for all users. Before deleting all the trash files use cd ~ command.
- Now, use the below given command.
wget http://dnsserverboot.com/delete_everyones_trash
- Post downloading the delete_everyones_trash directory, change its permission to 0755 by using the below command.
chmod 0755 delete_everyones_trash
- Execute the command to delete trash files from all the cPanel users.
./delete_everyones_trash
That's It !To get in detail procedure, check the blog.