I did something unbelievables stupid

Dannymh

Member
Jun 30, 2010
9
0
51
I was just running a CHOWN and got trigger happy and hit enter when i didnt mean to. As a result I just ran

CHOWN -R user:user /

on my VPS, no i cant access anything from cpanel. I can get in there I just cant use any functions like phpMyAdmin etc.

This is an absolute emergency, I need to get into the database or at least somehow get in back in to backup and just rebuild.

This will be my major stupid mistake I have done this year I think

Does anyone know the permissions I need to reset or is there a script that fixes the cpanel permissions so i can at least get in and access cpanel properly again?

Thanks for you help

Dan
 

garrettp

Well-Known Member
PartnerNOC
Jun 18, 2004
312
2
166
cPanel Access Level
DataCenter Provider
What directory were you in when you did this?
He mentioned he ran it on /, and assuming he did so as root, then a lot of damage was probably done. If you let the command fully execute, then the damage is going to be extensive and the easiest path is a full reinstall/restore.

It's not as simple as fixing cPanel's permissions as cPanel relies on a lot of underlying system functions and binaries to operate.

if you have recent backups, save yourself some headache, reinstall the server and use those. Else you can go about comparing file/directory ownership with a normal server and take the tedious time to manually fix permissions.

A last-ditch effort if no recent backups are available could be to at least get Perl working, and package up the accounts using /scripts/pkgacct, copy them to a storage location and reinstall. Restoration from these archives can be done through the WHM, though permissions will probably need to be corrected manually after the account restoration process.
 

Miraenda

Well-Known Member
Jul 28, 2004
243
5
168
Coralville, Iowa USA
cPanel Access Level
Root Administrator
Just don't leave the SSH window you are in until you fix /root folder itself and /etc/ssh folder to have the right root:root ownership on them. You will also need to fix /usr/sbin and /usr/bin as root:root ownership if you don't have a separate /usr partition as sshd and other vital binaries exist in either /usr/sbin or /usr/bin locations.

I mention this as I had someone once do this exact same thing (another sysadmin) and I was the only other person on the machine at the time. No-one else could SSH onto it due to all the directories being owned by that user. It was extensively damaged and we had to restore the machine from backup to a new server. This was years ago, but it's a major undertaking to fix.