Jump to content

Anyway to restore permission on Ubuntu?

I'm 99% sure I will have to do a full reinstall here but just in case someone knows something I don't....

 

I was up mega late last night trying to get my webserver to allow directory/file listing on a single folder (with it disabled globally) using a per folder override, because it was like 2am I missed a totally obvious mistake that I hadn't chown'd and chmodded the the files after I moved them over from my Windows PC.

 

I woke up very early (05:30) and literally the first thought was "a'ha, I didn't set permissions" so off I go to change them...

 

So after changing directory instead of running "sudo chmod -Rv 0775 ./*" I actually ran "sudo chmod -Rv 0755 /*" and totally destroyed my webserver. I stopped it as soon as I noticed but it got the /etc, /usr & /proc folders.

 

Funnily enough Apache still works fine however I cannot actually do anything with it since as soon as I SSH in I get "Warning: Sudoers list is publicly writeable" followed by "Warning: Sudoers list must be owned by group 0 and have GID bit set".

 

Some stuff that should require SUDO now works without it but mostly I just get errors when doing anything.

 

Really long shot, is there some magical way I can restore it back or am I spending my Saturday reinstalling it?

 

Thanks.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

you could try running "apt-get --reinstall install" (I assume its Ubuntu / Debian based?)

but considering you just chmodded your entire server, not sure hif that will fix it 

Spoiler

Desktop: Ryzen9 5950X | ASUS ROG Crosshair VIII Hero (Wifi) | EVGA RTX 3080Ti FTW3 | 32GB (2x16GB) Corsair Dominator Platinum RGB Pro 3600Mhz | EKWB EK-AIO 360D-RGB | EKWB EK-Vardar RGB Fans | 1TB Samsung 980 Pro, 4TB Samsung 980 Pro | Corsair 5000D Airflow | Corsair HX850 Platinum PSU | Asus ROG 42" OLED PG42UQ + LG 32" 32GK850G Monitor | Roccat Vulcan TKL Pro Keyboard | Logitech G Pro X Superlight  | MicroLab Solo 7C Speakers | Audio-Technica ATH-M50xBT2 LE Headphones | TC-Helicon GoXLR | Audio-Technica AT2035 | LTT Desk Mat | XBOX-X Controller | Windows 11 Pro

 

Spoiler

Server: Fractal Design Define R6 | Ryzen 3950x | ASRock X570 Taichi | EVGA GTX1070 FTW | 64GB (4x16GB) Corsair Vengeance LPX 3000Mhz | Corsair RM850v2 PSU | Fractal S36 Triple AIO | 12 x 8TB HGST Ultrastar He10 (WD Whitelabel) | 500GB Aorus Gen4 NVMe | 2 x 2TB Samsung 970 Evo Plus NVMe | LSI 9211-8i HBA

 

Link to comment
Share on other sites

Link to post
Share on other sites

Ufff that sounds horrible. Personally I would reinstall. I could probably supply you a txt file with the default permissions tree and you could use that to correct the permissions but wouldn't be able to trust that OS install ever again.

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, Jarsky said:

you could try running "apt-get --reinstall install" (I assume its Ubuntu / Debian based?)

but considering you just chmodded your entire server, not sure hif that will fix it 

Yeah, found this command on stack overflow, unfortunately apt wants SUDO which I cannot give it.

 

6 minutes ago, leadeater said:

Ufff that sounds horrible. Personally I would reinstall. I could probably supply you a txt file with the default permissions tree and you could use that to correct the permissions but wouldn't be able to trust that OS install ever again.

I'm backing up my apache confs and other important files ATM. This is going to be a fun day 😄

 

Edit - Well its a lesson learned anyway, I will never use relative pathing for anything important again, its absolute all the way.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, Master Disaster said:

Yeah, found this command on stack overflow, unfortunately apt wants SUDO which I cannot give it.

because of the warning about /etc/sudoers ?

You could boot up a Linux Live distro, mount the disk and change the permission on the sudoers file. It should be chmod 440 and owned by root:root

Spoiler

Desktop: Ryzen9 5950X | ASUS ROG Crosshair VIII Hero (Wifi) | EVGA RTX 3080Ti FTW3 | 32GB (2x16GB) Corsair Dominator Platinum RGB Pro 3600Mhz | EKWB EK-AIO 360D-RGB | EKWB EK-Vardar RGB Fans | 1TB Samsung 980 Pro, 4TB Samsung 980 Pro | Corsair 5000D Airflow | Corsair HX850 Platinum PSU | Asus ROG 42" OLED PG42UQ + LG 32" 32GK850G Monitor | Roccat Vulcan TKL Pro Keyboard | Logitech G Pro X Superlight  | MicroLab Solo 7C Speakers | Audio-Technica ATH-M50xBT2 LE Headphones | TC-Helicon GoXLR | Audio-Technica AT2035 | LTT Desk Mat | XBOX-X Controller | Windows 11 Pro

 

Spoiler

Server: Fractal Design Define R6 | Ryzen 3950x | ASRock X570 Taichi | EVGA GTX1070 FTW | 64GB (4x16GB) Corsair Vengeance LPX 3000Mhz | Corsair RM850v2 PSU | Fractal S36 Triple AIO | 12 x 8TB HGST Ultrastar He10 (WD Whitelabel) | 500GB Aorus Gen4 NVMe | 2 x 2TB Samsung 970 Evo Plus NVMe | LSI 9211-8i HBA

 

Link to comment
Share on other sites

Link to post
Share on other sites

Spoiler

Desktop: Ryzen9 5950X | ASUS ROG Crosshair VIII Hero (Wifi) | EVGA RTX 3080Ti FTW3 | 32GB (2x16GB) Corsair Dominator Platinum RGB Pro 3600Mhz | EKWB EK-AIO 360D-RGB | EKWB EK-Vardar RGB Fans | 1TB Samsung 980 Pro, 4TB Samsung 980 Pro | Corsair 5000D Airflow | Corsair HX850 Platinum PSU | Asus ROG 42" OLED PG42UQ + LG 32" 32GK850G Monitor | Roccat Vulcan TKL Pro Keyboard | Logitech G Pro X Superlight  | MicroLab Solo 7C Speakers | Audio-Technica ATH-M50xBT2 LE Headphones | TC-Helicon GoXLR | Audio-Technica AT2035 | LTT Desk Mat | XBOX-X Controller | Windows 11 Pro

 

Spoiler

Server: Fractal Design Define R6 | Ryzen 3950x | ASRock X570 Taichi | EVGA GTX1070 FTW | 64GB (4x16GB) Corsair Vengeance LPX 3000Mhz | Corsair RM850v2 PSU | Fractal S36 Triple AIO | 12 x 8TB HGST Ultrastar He10 (WD Whitelabel) | 500GB Aorus Gen4 NVMe | 2 x 2TB Samsung 970 Evo Plus NVMe | LSI 9211-8i HBA

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Jarsky said:

because of the warning about /etc/sudoers ?

You could boot up a Linux Live distro, mount the disk and change the permission on the sudoers file. It should be chmod 440 and owned by root:root

Thanks for the help, I really do appreciate it but I have to agree with Leadeater on this one, even if I did fix this I don't think I'd ever be able to trust it again and it is my one public facing server that hosts my website and a few other web services.

 

I'm biting the bullet, calling it a loss and reinstalling.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, Master Disaster said:

Thanks for the help, I really do appreciate it but I have to agree with Leadeater on this one, even if I did fix this I don't think I'd ever be able to trust it again and it is my one public facing server that hosts my website and a few other web services.

 

I'm biting the bullet, calling it a loss and reinstalling.

Got backups bro? 🤣

 

Every time this happens to me I always kick myself for not bothering to do backups of my home/lab stuff, I never learn though.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Master Disaster said:

Thanks for the help, I really do appreciate it but I have to agree with Leadeater on this one, even if I did fix this I don't think I'd ever be able to trust it again and it is my one public facing server that hosts my website and a few other web services.

 

I'm biting the bullet, calling it a loss and reinstalling.

No problem, it at least might be a good band aid to get stability and some security back in it to keep the server up while you rebuild and harden the replacement server. 

This is one of the good reason of why I run VM's, I do full backups of the VM disks every week, and snapshot the machine before I do any major work; even only being my home personal machines 🙂

 

P.S moving forward, if you just want to allow file listing on a single directory. In your webserver config make sure you specify "AllowOverride", and then put an .htaccess file in the directory you want to allow with Options +Indexes. So your apache conf will look something like this:

 

<Directory /var/www/>
        Options -Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

 

Spoiler

Desktop: Ryzen9 5950X | ASUS ROG Crosshair VIII Hero (Wifi) | EVGA RTX 3080Ti FTW3 | 32GB (2x16GB) Corsair Dominator Platinum RGB Pro 3600Mhz | EKWB EK-AIO 360D-RGB | EKWB EK-Vardar RGB Fans | 1TB Samsung 980 Pro, 4TB Samsung 980 Pro | Corsair 5000D Airflow | Corsair HX850 Platinum PSU | Asus ROG 42" OLED PG42UQ + LG 32" 32GK850G Monitor | Roccat Vulcan TKL Pro Keyboard | Logitech G Pro X Superlight  | MicroLab Solo 7C Speakers | Audio-Technica ATH-M50xBT2 LE Headphones | TC-Helicon GoXLR | Audio-Technica AT2035 | LTT Desk Mat | XBOX-X Controller | Windows 11 Pro

 

Spoiler

Server: Fractal Design Define R6 | Ryzen 3950x | ASRock X570 Taichi | EVGA GTX1070 FTW | 64GB (4x16GB) Corsair Vengeance LPX 3000Mhz | Corsair RM850v2 PSU | Fractal S36 Triple AIO | 12 x 8TB HGST Ultrastar He10 (WD Whitelabel) | 500GB Aorus Gen4 NVMe | 2 x 2TB Samsung 970 Evo Plus NVMe | LSI 9211-8i HBA

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, leadeater said:

Got backups bro? 🤣

 

Every time this happens to me I always kick myself for not bothering to do backups of my home/lab stuff, I never learn though.

Honestly, I don't consider any of it valuable enough to warrant the space for backing up. I've taken my Apache configs because I have some with proxy & rewrite rules that took me a while to get right but other than that, its nothing I cannot just redownload. Its only time. Luckily my SQL server is on my NAS so I've not lost anything from that.

 

1 minute ago, Jarsky said:

No problem, it at least might be a good band aid to get stability and some security back in it to keep the server up while you rebuild and harden the replacement server. 

This is one of the good reason of why I run VM's, I do full backups of the VM disks every week, and snapshot the machine before I do any major work; even only being my home personal machines 🙂

 

P.S moving forward, if you just want to allow file listing on a single directory. In your webserver config make sure you specify "AllowOverride", and then put an .htaccess file in the directory you want to allow with Options +Indexes. So your apache conf will look something like this:

 


<Directory /var/www/>
        Options -Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

 

You want to know the REALLY bad thing? This is in a VM 🤣🤣

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×