Restore Multiple cPanel Backups From SSH

cPanel restore multiple backups from ssh

From Terminal in cPanel or from an SSH session as root (or an account with backup restoring privileges), navigate to the folder the cPanel backup files are stored.

From that folder, run the following command:

for i in *; do /scripts/restorepkg --skipres --restricted $i; done;

–skipres will stop the restore from assigning reseller privileges if the backup contained them.

–restricted will restore the backup in restricted mode. This should be done when restoring a backup not created on the local server or a cPanel backup file that is from an untrusted source.

Find largest folder in SSH

Find largest folder in ssh

Is your cPanel server running out of space? Need to find out where the usage is coming from?

Finding the largest folder is as easy as running the following simply command from an SSH (or Terminal in cPanel’s WHM) session:

du -hs * | sort -rh | head -5

The above command will output the largest folders in the current directory in a human readable format that is easy to understand.

You can continue to further nail down the source of the usage by entering the next folder and entering the above command again and again until you find the exact source of the high usage.

Force CloudLinux License Update

update cloudlinux license ssh

Has your CloudLinux expired and you have renewed it, but LVE Manager still sees the old license?

Have you changed the license and it is not seeing the new license?

You can run the following command from SSH to force an update of the CloudLinux license:


clnreg_ks –force 


Once ran you should be abe to go to LVE Manager and see the license reactivated if your license is valid. 

cPanel server booting to grub menu

Find largest folder in ssh

So you recently updated and you rebooted and now your cPanel server is not booting and instead booting to a Grub prompt?:




This is typically due to the system not being able to find the root partition in Grub, so it boots to the Grub menu to allow you to further diagnose why it is not booting.

How do I fix this?

First, you need to find the partition Grub is located. Using the "ls" command to list the current partitions you can find it:




This will list the partitions, such as (hd0,1) (hd0,2) (md/md2), etc.

In this example, we will assume the partition is "(md/md2)".

We can then look further for "grub" by running:


ls (md/md2)/


That will list all folders in " / " on that partition.

In this example, grub was located in "/boot/grub".

Now we need to set the boot parameters using the above info we just got and then boot normally (Enter each line at the grub prompt and press enter after each line):


set prefix=(md/md2)/boot/grub
set root=(md/md2)
insmod linux
insmod normal


If you entered the above correctly and set the correct path to Grub, the system should now boot normally!

If the above does not work, check your syntax and check that your path to Grub is correct. There are several "flavors" of Linux, so your path to Grub may be different than the above example.

Good luck!


Find Current Inode Usage Using SSH

Find largest folder in ssh

Need to find out how many inodes each user is using on your cPanel server?

Simply run the following command from SSH:


cd /home

echo "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"


The above command will create a list of users and their current inode usage. The list can be long depending on how many users you have.

cPanel Find and Delete Trash Folders

cPanel restore multiple backups from ssh

If you find you have a lot of users with large amounts of files in their Trash in cPanel, you can run the following command from SSH to delete them all in one go!:


find /home/*/.trash/* -exec rm -rf {} \;


Keep in mind it is not possible to retrieve any data in the folders you are deleting, so only do this if you know what you are doing and are absolutely sure you do not need the data! 

Find and Remove a File or Folder in SSH

Find largest folder in ssh

Need to find and remove a particular file and/or folder and know the name, but not the location?

Use the following command to find and remove it!:

find . -name "error_log" -exec rm -rf {} \;


The above will search the current folder and subfolders for the file named "error_log" and delete every one it finds.

You can substitute "error_log" with any file or folder name you want!

IP addressing MISSING in WHM List Accounts

cPanel restore multiple backups from ssh

When in List Accounts in cPanel's WHM, you find an account with the IP address set as "MISSING", try the running the following command from SSH:




After running the above command, make sure to restart the HTTPD service.


Another alternative quick fix is to change the accounts IP address to another IP and then back to the original, which will also typically fix this issue.


cPanel Log Locations

cPanel restore multiple backups from ssh



All cPanel logs are located in the folder:


The access_log contains all traffic to WHM, cPanel, and Webmail:


The error_log contains all errors when accessing a cPanel related site:




On cPanel servers each site has its own traffic log, but Apache's main access log can be viewed here:


To view each cPanel accounts individual access-logs:


Apache errors are logged to the error_log file:




The exim main log contains all transaction information:


The reject log contains all connections that were rejected:




Regardless of the FTP server chosen in cPanel, it does not have it's own log and instead logs to:




On most servers the SSH service will log to the secure and system messages log files:





Manually Export MySQL Database

Find largest folder in ssh

How do I manually export or "dump" a MySQL database from command line or SSH?

You can dump a MySQL database to the current folder from an SSH session using the following command:

mysqldump –no-create-db=true -uUSERNAME -pPASSWORD DATABASE > filename.sql

So if your database name is "USER_MYDATABASE" and your database username is "USER_USER1" and the password is "PASSWORD1" and you would like to save the dump as "mydump.sql", you would use the following:

mysqldump –no-create-db=true -uUSER_USER1 -pPASSWORD1 USER_MYDATABASE > mydump.sql




Search For Specific Text In File

Find largest folder in ssh

How can I find a specific text string in a file or multiple files from an SSH session?

You can use the grep command to easily find text within files.

From an SSH session, run the following command:

grep -H -r "<Text-To-Find>" <search-location>

Where <Text-To-Find> would be replaced with the text you want to search for and <search-location> is where the files are located that you want to search within.

For example, if you wanted the find all files containing the string "base64_decode" in the home folder, you would use:

grep -H -r "base64_decode" /home




Bulk Edit DNS Zone On cPanel

cPanel restore multiple backups from ssh

How do I bulk edit a DNS zone on cPanel?

Changed nameserver name and need to update all the DNS zones on your cPanel server?

Using the replace command from an SSH session will make it simple.

Just use the following command:

replace "<old-nameserver>" "<new-nameserver>" — /var/named/*.db

Where <old-nameserver> is the hostname of the old nameserver and <new-nameserver> is the new namserver hostname you want to replace it with.

You should then restart the DNS service:

service named restart




Explanation Of Cron Times

Find largest folder in ssh

New to setting up cron jobs and need to know what each digit means?

The following is an example of each digit and its function:

*    *    *    *    *        command to be executed
|     |     |    |    |
|     |     |    |    +—– day of week (0 – 6) (Sunday=0)
|     |     |    +——- month (1 – 12)
|     |     +——— day of month (1 – 31)
|     +———– hour (0 – 23)
+————- min (0 – 59)



Find And Remove Old cPanel Backups

cPanel restore multiple backups from ssh

How do I find and remove old cPanel backups?

Use the following command from an SSH session to find all backups that are older than 60 days and delete them:

find /backup/weekly/incremental/accounts -maxdepth 1 -type d -ctime +60 -exec rm -rf {} \;

In the above example we find all weekly incremental backups that are older than 60 days and delete them.

You can change the folder location to suit your needs.

Please note: Be very careful to make sure you get the folder path right because it does not prompt you for approval and goes simply by age, so it does not know the difference between a backup folder and an unrelated folder.