Change Domain Name for cPanel Account from SSH Terminal

This article provides a quick workaround for changing the primary domain name of a cPanel account. Root-equivalent access is required.

How to Change Domain Name for cPanel Account from SSH Terminal

In the case that the cPanel account domain name should be quickly modified (such as username.net -> username.com), the following procedure can solve the issue.

Prerequisites

  • Requires full root access
  • cPanel installed on server
  • Recent backup of account which is to be modified (in this example, the account backup is located in /home/backupuser/backup.tar.gz)

Procedure

As root-equivalent user, access the server via SSH and run the following commands:

/scripts/removeacct --force username
/scripts/restorepkg --force --ip=xxx.xxx.xxx.xxx /home/backupuser/backup/cpmove-username.tar.gz
mv /var/cpanel/userdata/username/username.com /var/cpanel/userdata/username/username.net
mv /var/cpanel/userdata/username/username.com.cache /var/cpanel/userdata/username/username.net.cache
sed -i -e 's/username\.com/username\.net/g' /var/cpanel/userdata/username/username.net 
rm -f /var/cpanel/userdata/username/cache
sed -i -e 's/username\.com/username\.net/g' /var/cpanel/userdata/username/main
rm -f /var/cpanel/userdata/username/main.cache
sed -i -e 's/username\.com/username\.net/g' /var/cpanel/users/username
mv /var/named/username.com.db /var/named/username.net.db
sed -i -e 's/username\.com/username\.net/g' /var/named/username.net.db
sed -i -e 's/username\.com/username\.net/g' /etc/named.conf
/scripts/updateuserdomains
/scripts/updateuserdatacache --force username
/scripts/rebuildhttpdconf
/scripts/restartsrv_apache
rndc reload
#Changing Password
export ALLOW_PASSWORD_CHANGE=1
/scripts/chpass username myhardpassword
#Synching FTP pass
/scripts/ftpupdate

Use the following guidelines for creating the above commands with your custom data:

  • Substitute the cPanel account username for "username"

  • Substitute the IP Address for "xxx.xxx.xxx.xxx"
  • Substitute existing domain name for "username.net"

  • Substitute the new domain name for "username.com"

  • Substitute the cPanel account password for "myhardpassword"

Conclusion

You now know how to change domain name for cPanel account from SSH terminal.

  • cpanel shortcut, modify domain, change domain, cpanel workaround, cli workarounds, cpanel cli, cpanel scripts
  • 11 Users Found This Useful
Was this answer helpful?

Related Articles

Guide to Domain EPP Status Codes

EPP Status Codes are used by the Domain Registry to signify the status of a particular domain...

Addon Domain Vs Alias Domain

The table below lists some key characteristics of Addon Domain and Alias Domain....

Disable Network Manager on CentOS 7

This article will provide the steps to disable Network Manager in CentOS 7. Network Manager is...

Disable Network Manager on CentOS 6

This article will provide the steps to disable Network Manager in CentOS 6. Network Manager is...

Video: How to Setup Domain Redirects in cPanel

This video tutorial provides Step-by-Step instructions how to setup domain redirects in cPanel...