Ubuntu: What “chmod 777 -R / ” does in /var/www/html/…/…/…/? [duplicate]


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 (/) ?


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 do setfacl --restore=permissions.txt in / to restore them.

I would advise you to re-install though.


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/passwdand 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.


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  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »