While trying to debug a mail server, I typed:
chmod -R 777 /
instead of:
chmod -R 777 .
and the icing on the cake, due to me forgetting I had changed a script I use to sign in to fix something, I did all this as root. I do not have backups of most of the system (poor choice I know).
Unlike in the questions "Recovering from chmod -R -777 /" and "What to do after 'chmod -R 777 /'?" i am still signed in as root, and not the whole system was changed, so I do have some control over the system. I also ^C d out of the command within one second to minimize damage. Since then I have physically disconnected the server from the internet.
I believe a script could fix it if it restored the permissions of the filesystem based on data from the package manager, but i do not know how I would go about doing this. If this is not possible, how would I save the data from the server to reinstall the OS?
I am aware of the potential risks of missing a file, but would prefer recovery to reinstall despite them.
this is the current output of ls -la /
:
drwxrwxrwx 22 root root 4096 Sep 7 2016 .
drwxrwxrwx 22 root root 4096 Sep 7 2016 ..
drwxr-xr-x 2 root root 4096 May 18 07:55 bin
drwxr-xr-x 3 root root 4096 Sep 21 07:53 boot
drwxr-xr-x 19 root root 3180 Sep 11 20:54 dev
drwxrwxrwx 92 root root 4096 Aug 23 07:50 etc
drwxr-xr-x 4 root root 4096 May 23 2016 home
lrwxrwxrwx 1 root root 31 Feb 24 2016 initrd.img -> /boot/initrd.img-3.16.0-4-amd64
drwxrwxrwx 18 root root 4096 Feb 24 2016 lib
drwxr-xr-x 2 root root 4096 Jun 20 07:00 lib64
drwx------ 2 root root 16384 May 19 2016 lost+found
drwxrwxrwx 2 root root 4096 May 5 2015 media
drwxr-xr-x 2 root root 4096 May 5 2015 mnt
drwxr-xr-x 3 root root 4096 May 28 2016 opt
dr-xr-xr-x 148 root root 0 Sep 3 21:55 proc
drwxrwxrwx 10 root root 4096 Aug 19 17:58 root
drwxr-xr-x 22 root root 800 Sep 21 17:09 run
drwxrwxrwx 3 root root 4096 Jun 20 07:00 sbin
drwxr-xr-x 4 root root 4096 Sep 20 23:18 sftp
dr-xr-xr-x 13 root root 0 Sep 3 21:55 sys
drwxrwxrwx 8 root root 4096 Sep 21 17:17 tmp
drwxrwxrwx 11 root root 4096 Feb 24 2016 usr
drwxr-xr-x 14 root root 4096 Jun 25 06:21 var
lrwxrwxrwx 1 root root 27 Feb 24 2016 vmlinuz -> boot/vmlinuz-3.16.0-4-amd64
just noticed in my panic i clicked ubuntu forum not debian... im aware thats not how you fix a mail server. it was a hacky sloppy fix to see what broke
iv reposted this in the correct forum now
CHMOD
notchmod
your fine – George Udosen Sep 21 '17 at 18:41CHMOD
orchmod
? These aren't the same commands. And as such you probably didn't harm your system if you used all caps. – Thomas Ward Sep 21 '17 at 18:42chmod
previously as I see certain file such as/etc
,/root
, etc have permissions set to777
? – George Udosen Sep 21 '17 at 19:36debian
OS? – George Udosen Sep 21 '17 at 19:58chmod
and the only reason not everything is completely borked is that they Ctrl C'd it so fast. As such, the best hope for recovery is terdon's answer to set myself as owner of /etc... – Zanna Sep 21 '17 at 21:07/usr
and/media
are gone too. Since it's Debian you may want flag for migration to [unix.se]... – Zanna Sep 21 '17 at 21:17