Unfortunately I was rushing and ran sudo chmod 777 -R /
inside one project. Should I worry that it started to add 777 permission for all my folder starting from root (/
) ?
4 Answers
Should I worry that it started to add 777 permission for all my folder starting from root(/) ?
No, no need to worry. I can guarantee it if you used "sudo" in front of it or did a "sudo -i". Otherwise it should have shown a permissions error.
In case you want to restore your system there are ways to do this but you need a current (ie. up to date with your personal data) backup system. With ACL tools ...
you can do
getfacl -R > permissions.txt
from/
on the backup system to create a list of permissions.On the broken machine use a live session, copy the file to
/
and dosetfacl --restore=permissions.txt
in/
to restore them.
I would advise you to re-install though.
-
Oh ! So nice to learn this. I will star this question for futur reference ! Jul 27, 2017 at 14:04
-
4Leaving every file present on your local machine and not on the remote one with potentially broken permissions (world-write and world-execute, meaning even a completely untrusted account like
nobody
can alter an executable any other user might run) doesn't exactly strike me as adequate fix. Jul 27, 2017 at 15:44 -
1
Yes, you absolutely need to worry
You ran sudo chmod 777 -R /
, which will recurse through the whole file system.
For most files, this is a minor inconvenience. For some files it will be a serious security risk (think /etc/passwd
and the like), if some attacker manages to compromise your system via shell or CGI attacks.
But most importantly, some files break if they are too open. For example, if you open up ~/.ssh/*
(your ssh keys, authorized_keys, hosts...), then ssh
or sshd
will treat those files as if they were not there, for security reasons. This could, worst case, mean that you become locked out of your own machine, if you relied on ~/.ssh/authorized_keys
to log in via ssh+Public Key. There are also plenty of other security related software packages that do the same, mostly for their configurations in /etc
or maybe some files in /var
.
So while we obviously cannot say for sure as we know little about your machine. It is certainly not a harmless issue, as some of the other answers propose.
If you run:
readlink -f /var/www/html/../../..
You'll get /
it means as you said it your self your command has been run on the /
, simply your system is broken now, get a backup of your data, re-install the Ubuntu.
chmod
's job is to change the mod (permission bit) of files/directories and 777
means every one can read, write, execute anything on your system, at the same time you have removed a lot of other bits like sticky, suid, sgid.
-
But only user root can do this. As a normal user, not much damage is done. Did OP run as root or not ?– Soren AJul 27, 2017 at 13:24
-
Those are ellipses (i.e.
...
), not..
. He probably meant he was in a long subdirectory under /var/www/html, when he ran the command passing it/
as an argument.– JoLJul 27, 2017 at 17:56
On a point that hasn't been raised,
...it started to add 777 permission for all my folder starting from root...
You didn't just add 777 permissions, you removed the setuid, setgid, and sticky bit from all files. This'll cause things like sudo
and su
to stop working, since they rely on setuid to change users.
Note that chmod 777
is short for chmod 0777
. That other octal digit represents the bits I just mentioned. For example, chmod 4777
, sets the setuid bit, clears the setgid and sticky bit, and adds all permissions.
In the future, I suggest using chmod
's other syntax:
chmod +rwx # what you probably intended
chmod ug+w # add write permission to user and group
chmod o-r # remove read permission from other
chmod 777 -R /
then everything is broken./
is the absolute path of the top level directorysudo chmod ...
) That could limit the damage done to the point where it might be reversible.