Help! Accidental change of ownership in the folder /var, how to get back?

kendrive

Registered
Aug 2, 2012
3
0
1
cPanel Access Level
Root Administrator
Good day,

Accidentally changed user and group folders in /var, tell me how to get back? It is necessary, all sites do not work!

Here's a chance the team performed chown -R root:root /var


:confused::eek:
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Re: Help! Accidental change of ownership in the folder /var, how to get bac

Most folders in /var are owned by root:root even /var/cpanel other than /var/cpanel/tmp folder (which is owned by cpanel:cpanel) and /var/named folder (which is owned by root:named) and /var/lib/mysql (which is owned by mysql:mysql). I'd suggest changing /var to root:root for everything and then changing /var/named to root:named for the top level and named:named for the contents along with /var/lib/mysql

Something like the following:

Code:
chown -R root:root /var
chown -R cpanel:cpanel /var/cpanel/tmp
chown -R named:named /var/named
chown root:named /var/named
chown mysql:mysql /var/lib/mysql
Please note to anyone reading the above, this is only for this user due to the emergency situation and please do not run these commands yourself for any reason.

After you've gotten the above to function, please then try to make backups and migrate accounts to another machine if you are still having issues. You should at least be able to get working backups doing the above.
 

kendrive

Registered
Aug 2, 2012
3
0
1
cPanel Access Level
Root Administrator
Re: Help! Accidental change of ownership in the folder /var, how to get bac

Thank you!
However, you can do without reinstalling the server? Currently, only the function does not work, and sendmail is I think due to the fact that in the directory /var/сpanel are not correct user and group.
 

Eric

Well-Known Member
Nov 25, 2007
754
12
143
Texas
cPanel Access Level
Root Administrator
Twitter
Re: Help! Accidental change of ownership in the folder /var, how to get bac

Howdy,

It's a lot of shell bashing but you could just compare to a known good example and chmod away. But aside from that you might be looking at a lot of meticulous work to get the server up and running again.

Thanks!
 

kendrive

Registered
Aug 2, 2012
3
0
1
cPanel Access Level
Root Administrator
Re: Help! Accidental change of ownership in the folder /var, how to get bac

I understand that it takes a long time, but I'm ready for it. Potmou that the stop work sites for a few hours is not desirable.
Where can I get documentation on this issue?
 

syndicated

Member
Jun 1, 2010
14
0
51
Re: Help! Accidental change of ownership in the folder /var, how to get bac

Don't you have a backup anywhere?

If not the command to list all non ROOT in var is

find /var ! -user root -type d -ls

and where i put .... means same as ABOVE for anything in there

Code:
9683596    4 drwx------   3 daemon   daemon       4096 Aug  6 03:59 /var/spool/at
9683597    4 drwx------   2 daemon   daemon       4096 Aug  6 03:59 /var/spool/at/spool

9765355    4 drwxr-x---   6 mailnull mail         4096 May 28  2010 /var/spool/exim

9765383    4 drwxr-x---  64 mailnull mail         4096 Oct 25  2009 /var/spool/exim/input

9765423    4 drwxr-x---   2 mailnull mail         4096 Aug  6 14:48 /var/spool/exim/input/b
9765428    4 drwxr-x---   2 mailnull mail         4096 Aug  7 00:08 /var/spool/exim/input/g
......

9765385    4 drwxr-x---   5 mailnull mail         4096 Aug  7 00:18 /var/spool/exim/scan
.......

9765384    4 drwxr-x---  64 mailnull mail         4096 Oct 25  2009 /var/spool/exim/msglog
9765554    4 drwxr-x---   2 mailnull mail         4096 Aug  6 14:48 /var/spool/exim/msglog/b
9765559    4 drwxr-x---   2 mailnull mail         4096 Aug  7 00:08 /var/spool/exim/msglog/g
.......

9765382    4 drwxr-x---   2 mailnull mail         4096 Apr 18 14:01 /var/spool/exim/db

9765349    4 drwxr-x---   2 daemon   mail         4096 Aug  8  2011 /var/spool/authdaemon

9290116    4 drwxrwx---   2 nobody   nobody       4096 Apr 28 02:35 /var/asl/data/suspicious

9290114    4 drwxrwx---   2 nobody   nobody       4096 Apr 28 03:01 /var/asl/data/msa

9290115    4 drwxrwx---   2 nobody   nobody       4096 Apr 29 20:21 /var/asl/data/audit

9342440    4 drwxr-x---   2 dovecot  dovecot      4096 Aug  4 11:05 /var/lib/dovecot

9342446    4 drwxr-x--x  58 mysql    mysql        4096 Aug  4 06:22 /var/lib/mysql
9342535   20 drwx------   2 mysql    mysql       20480 Aug  3 21:23 /var/lib/mysql/ANYTHING
.....

9765224    4 drwxr-xr-x   2 avahi    avahi        4096 Apr 23 19:47 /var/run/avahi-daemon

9765230    4 drwxrwx---   2 named    named        4096 Aug  1 03:36 /var/run/named

9338988    4 drwxr-xr-x   2 cpanel   cpanel       4096 Aug  6 03:41 /var/cpanel/tmp

9340593    4 drwx------   2 cpanelhorde cpanelhorde     4096 Nov 27  2009 /var/cpanel/horde/tmp

9340592    4 drwx------   2 cpanelhorde cpanelhorde     4096 Jul 23  2009 /var/cpanel/horde/log

9342268    4 drwx--x--x   3 cpaneleximfilter cpaneleximfilter     4096 Dec 29  2010 /var/cpanel/userhomes/cpaneleximfilter

9342277    4 drwxr-x---   2 cpaneleximfilter cpaneleximfilter     4096 Dec 29  2010 /var/cpanel/userhomes/cpaneleximfilter/mail

9342269    4 drwx--x--x   4 cpanelhorde cpanelhorde     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelhorde

9342278    4 drwxr-x---   2 cpanelhorde cpanelhorde     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelhorde/mail

9342279    4 drwx------   2 cpanelhorde cpanelhorde     4096 Apr  5 03:42 /var/cpanel/userhomes/cpanelhorde/sessions

9342271    4 drwx--x--x   4 cpanelphppgadmin cpanelphppgadmin     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelphppgadmin

9342282    4 drwxr-x---   2 cpanelphppgadmin cpanelphppgadmin     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelphppgadmin/mail

9342283    4 drwx------   2 cpanelphppgadmin cpanelphppgadmin     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelphppgadmin/sessions

9342272    4 drwx--x--x   4 cpanelroundcube cpanelroundcube     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelroundcube

9342284    4 drwxr-x---   2 cpanelroundcube cpanelroundcube     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelroundcube/mail

9342285    4 drwx------   2 cpanelroundcube cpanelroundcube     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelroundcube/sessions

9699494    4 drwx--x--x   3 cpanellogaholic cpanellogaholic     4096 Apr  5 03:41 /var/cpanel/userhomes/cpanellogaholic

9699495    4 drwxr-x---   2 cpanellogaholic cpanellogaholic     4096 Apr  5 03:41 /var/cpanel/userhomes/cpanellogaholic/mail

9342267    4 drwxr-xr-x   4 cpanel   cpanel       4096 Dec 16  2009 /var/cpanel/userhomes/cpanel
9342274    4 drwxr-xr-x   2 cpanel   cpanel       4096 Jul 25 03:41 /var/cpanel/userhomes/cpanel/cpanelbranding
9342273    4 drwxr-xr-x   3 cpanel   cpanel       4096 Dec 16  2009 /var/cpanel/userhomes/cpanel/.cpanel
9342275    4 drwxr-xr-x   4 cpanel   cpanel       4096 Apr  5 03:42 /var/cpanel/userhomes/cpanel/.cpanel/caches
9818516    4 drwxr-xr-x   2 cpanel   cpanel       4096 Apr  5 03:42 /var/cpanel/userhomes/cpanel/.cpanel/caches/dynamicui
9342276    4 drwxr-xr-x   2 cpanel   cpanel       4096 Dec 16  2009 /var/cpanel/userhomes/cpanel/.cpanel/caches/dyanmicui

9683960    4 drwx--x--x   4 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin
9683961    4 drwxr-x---   2 cpanellogin cpanellogin     4096 Apr  5 03:41 /var/cpanel/userhomes/cpanellogin/mail

9818543    4 drwx------   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles

9818544    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr

9818545    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local

9818546    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local/cpanel

9818547    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local/cpanel/base

9818548    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local/cpanel/base/unprotected

9818549    4 drwxr-xr-x   3 cpanellogin cpanellogin     4096 Apr  5 07:33 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local/cpanel/base/unprotected/cpanel

9818551    4 drwxr-xr-x   2 cpanellogin cpanellogin     4096 Jun  5 04:03 /var/cpanel/userhomes/cpanellogin/template_compiles/usr/local/cpanel/base/unprotected/cpanel/templates

9342270    4 drwx--x--x   4 cpanelphpmyadmin cpanelphpmyadmin     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelphpmyadmin

9342280    4 drwxr-x---   2 cpanelphpmyadmin cpanelphpmyadmin     4096 Jul 23  2009 /var/cpanel/userhomes/cpanelphpmyadmin/mail

9342281    4 drwx------   2 cpanelphpmyadmin cpanelphpmyadmin     4096 Oct 29  2011 /var/cpanel/userhomes/cpanelphpmyadmin/sessions

9338926    4 drwx------   2 cpanel   cpanel       4096 Jul 23  2009 /var/cpanel/.cpanel

9341734    4 drwx------   2 cpanelroundcube cpanelroundcube     4096 Apr 23 12:54 /var/cpanel/roundcube/tmp
9341733    4 drwx------   2 cpanelroundcube cpanelroundcube     4096 Sep 15  2010 /var/cpanel/roundcube/log

9765216    4 drwxrwx---   2 named    named        4096 Jul 23  2009 /var/named/chroot/var/run/named
9765187    4 drwxrwx---   2 named    named        4096 Jul 23  2009 /var/named/chroot/var/named/data
9765196    4 drwxrwx---   2 named    named        4096 Jul 23  2009 /var/named/chroot/var/named/slaves
9765170    4 drwxrwx---   2 named    named        4096 Jul 30 21:17 /var/named/data
9765171    4 drwxrwx---   2 named    named        4096 Jul 30 21:17 /var/named/slaves
- - - Updated - - -

Would really only take you maybe 20 mins or so to manually mod them all back to normal with Chown -R commands