4

I accidentally ran chmod 777 * (without the -R parameter) on my home directory.

Will It be a problem? Then how to solve it?

  • Did you run chmod 777 * or chmod -R 777 *? One of these two is a lot worse than the other, so... – Kaz Wolfe Jan 10 '17 at 5:27
  • Are you saying you ran "chmod 777 *" from within your home directory? – theferrit32 Jan 10 '17 at 5:27
  • chmod 777 * withing home directory – amiranga Jan 10 '17 at 5:34
  • 2
    What command did you run exactly ? with or without sudo ? with or without -R? what problems are you having ? – Panther Jan 10 '17 at 5:46
  • @bodhi.zazen does sudo really matter in the home directory? – TheWanderer Jan 10 '17 at 15:14
13

If you ran just chmod 777 * and not the evil chmod -R 777 *, you haven't really done much bad to your system.

Notably, however, every top-level file and directory will need to be restored to their original permissions. Fortunately, this is a relatively simple operation. Simply run the below command:

chmod a=r,u+w,a+X *

This will do some fancy magic to reset all folder permissions back to 644 for files (the default) and 755 for folders (again, the default). See this Stack Overflow answer for a more detailed idea of how this command works.

From there, permissions should be reset to default. You may additionally need to change some other permissions back to what they were before, but this should (at the least) undo the damage.

Notably, you also want to run these two commands:

chmod 700 .ssh
chmod 600 .Xauthority

This will prevent any authentication errors either relating to X11 or SSH due to mismatched permissions. While these shouldn't matter, it's better to be safe than sorry.


In all honesty, running chmod on your home directory isn't the absolute worst thing in the world. While it can cause problems with things like SSH and Xauthority, it's pretty far from "catastrophic" as you own all the files in your home dir, and (ideally) only you should have access to them.

Given this, it's perfectly safe (but not necessarily the best idea) to just be lazy here and deny access to your entire home-folder to users that are either not yourself or not root. You can do this by running the below command:

chmod 700 ~

Effectively, this will allow only your user to access your home folder. Other users (except for root -- which has access to everything anyways) will have no way at all to access your home folder, and as such it doesn't really matter that everything inside is set to world-readable/writeable/executable.

If you just do this and call it a day, though, some systems (again) like Xauthority and SSH may complain, so pay heed to that. Similarly, some services that have a legitimate need to access your home folder under a different user account will also no longer be able to. You can somewhat solve this issue through advanced permissions-fu and ACLs, but that's just going down a very dark and windy rabbit-hole.

| improve this answer | |
  • Here, a+X is no different from a+x, since all files have already been granted execute permissions. – muru Jan 10 '17 at 5:45
  • 2
    @muru Nope, it's not. a=r resets everything to 444. a+X will only grant execute to directories, see man chmod: "execute/search only if the file is a directory or already has execute permission for some user (X)" – Kaz Wolfe Jan 10 '17 at 5:45
  • 1
    Ah, yes. That's a nice use of a=r. – muru Jan 10 '17 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.