Question

Accidentally did "chmod -777 /"

Posted September 26, 2021 129 views
BackupsLinux Commands

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?

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.

×
Submit an Answer
2 answers

Hello,

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

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.

  • Hello,

    Thank very much for you reply.

    I don’t have snapshot or backup :/

    If I create a new droplet and move the data from the old to a new one, will I be able to fix the problem?
    I saw that there is a feature called “Move resource” after creating the new one droplet. Would it be this?

    • A new Droplet will definitely not have this issue. On the subject of “Move Resource” feature, that is to just move Droplets from one project to another and doesn’t move the Droplet to a new Droplet.

      You will need to manually create a new server, and then copy data from the old server to it from CLI.

      • I managed to re-establish the connection to my sites by restarting the droplet, this partially solved my problem. Now I need to re-establish the connection via FTP/SSH that is being denied. Can you think of any solution for this?