Accidentally did "chmod -777 /"

I accidentally gave the command chmod -777 to all folders on my server and with that all my sites that were in my droplet crashed and are “Error establishing a database connection”. I’ve already researched on ways to reverse this but without success. What they advised would be to format my VPS. But I can’t lose my sites. Is there a way to backup all sites and restore after formatting the VPS?


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you have a snapshot of the server or a backup that you can restore from, I would recommend that. Otherwise, you can create a new Droplet and move the data over to it using any file transfer tool like scp, sftp etc. You can use the recovery ISO to access and move data.


If you’ve run the command without a -R flag this would mean that you’ve changed the permissions only for the / directory and not all subfolders.

If this is the case, the fix would be to revert back the permissions to 755:

chmod 755 /

However, if you actually added the -R flag, then indeed the best thing to do would be to actually revert to a backup or a snapshot.

Regards, Bobby