J
J
JunDevTest2018-07-16 07:00:03
ubuntu
JunDevTest, 2018-07-16 07:00:03

How to roll back file permissions an hour ago in Ubuntu?

Guys, help me out. I have a VestaCP panel, everything worked fine 15 minutes ago. Then I restarted nginx and got a "500" error on one of the hosts, I was told that it was a matter of file permissions. The fact is that I threw the files through wget under my user and then changed them to the rights and the owner, which vesta sets by default. This unfortunately didn't help. After that, I decided to set permissions to 777 on the ENTIRE system, that is, chmod -R 777 / but without waiting for the result, I canceled part of the operation.
Then he applied the rights 777 to the /home and /etc folders, after which the sudo command stopped working. I realized that I had done a great x*nu and decided to correct the situation with the command chmod -R 755 /. Sudo worked, I rebooted...
As a result, Vesta writes "Internal vesta error", all hosts crashed with a "500" error, when trying to connect to SSH, it writes the error "Server unexpectedly closed network connection".
But the other panel works fine, there is a shell and root access.
How can I roll back the system 15 minutes ago? Perhaps somehow it is possible to cancel chmod or somehow solve this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
JunDevTest, 2018-07-16
@JunDevTest

The question is not relevant.
The solution in my case (may work in yours too):

/usr/local/vesta/upd/add_sudo.sh && chmod 0440 /etc/sudoers && chown root:root /etc/sudoers
 && chmod 0440 /etc/sudoers.d/admin && chown root:root /etc/sudoers.d/admin && chown root:root /usr/bin/sudo
 && chmod 4755 /usr/bin/sudo

And so, by analogy, something worked, now it does not work or does not work correctly? Try changing file permissions.

E
Eugene Wolf, 2018-07-16
@Wolfnsex

There is a suspicion that "to roll back the rights in the system to" 15 minutes ago "- nothing if a snapshot of the system or something like that has not been made before ... but there is a solution that is relatively not difficult.
1. Take the same exactly the system (for example, a similar server)
2. Write a script that will iterate over the entire file system and write to a text file, in the line: path to the file (directory) + rights to it
3. Upload the finished file with the resulting result to the server and run the reverse an operation similar to a script (setting rights in accordance with the specified path)
Or, take a similar working server and transfer all the data there ...
PS Perhaps there are more beautiful solutions, or even some system scripts (ready-made) that will set the necessary rights correctly, but, "quickly", the solution that I voiced above comes to my mind.

A
Artem Spiridonov, 2018-07-16
@customtema

Then I restarted nginx and got a "500" error on one of the hosts, I was told that it was a matter of file permissions.

Tin. Why go there if you don't understand so much?
The system can be simply rearranged so as not to suffer. Error 500 is treated by artistic reading of the log (did you find it at all???) and subsequent relaxing googling. It is highly desirable to find a person who is accountable for his actions, and at least a little understands how the server works.
When the time comes, read some Ubuntu Server Guide or something.
PS Really, there is nothing complicated, but you need to figure it out.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question