2

I accidentally executed the following: chmod -R 741 /* (forgot the dot, yes). So the next thing I know is my terminal riddled with errors and I stop it in /mnt/ directory. At this point I realise what a terrible mistake I made and my terminal hangs dead. After some poking around I returned 755 to my home directory and everything seems working fine now. However, could I break something in the system? I didn't use sudo so I guess I didn't screw up too bad? And can I restore at least some default permissions for the home dir, granted that I have another user untainted by my blunders?

  • 1
    If you did it without elevated privileges, you are probably more or less in the clear. You may have a few random "permission denieds" that pop up here or there, but it probably isn't anything too scary – Gravy Aug 1 '16 at 18:32
1

As others have pointed out, without root permissions you won't have damaged any part of the system itself. You will have changed permissions on files and directories that you own.

Here is how you can return them to a (mostly) sane set of values:

chmod u=rwx,go= ~                                              # Ensure we can access our home directory
cd                                                             # Let's go...
find . -type d -exec chmod u=rwx,go=rx {} +                    # All directories
find . ! -type d -exec chmod u=rw,go=r {} +                    # Everything else
find .bash_history .config .gnupg .ssh -exec chmod go= {} +    # Lock out sensitive data

This will set all directory permissions so that you can read/write/search them, and everyone else can read/search them. Change go=rx to go= if you want to prevent anyone accessing your directories.

It will then set all file permissions so that you can read/write them, and everyone else can read them. Change go=r to go= if you want to keep your file contents private.

Finally, it will remove all access for sensitive directories for everyone except yourself.

If you have any executable files (programs, scripts) you will need to add the executable bit back in:

chmod a+x ~/some/important/program

As before, this gives everyone ("all") rights to execute the program. Change a+x to u+x if you want that right just for yourself.

  • Thanks! I also had to adjust permissions on /var/tmp/kdecache-username and run kbuildsycoca4 because krusader was crashing and stuff. – Yuri Drobkov Aug 3 '16 at 5:53
1

Since you ran this without using sudo any file or directory that is system critical will not have been affected.

You may have changed the permissions on all your own files and directories though, and depending on what you have in $HOME, this may or may not be a big issue for you.

You may have made all your files executable by yourself and by "others". It would be fairly simple, on a small set of files, to manually change the permissions for regular files back to 644 (755 for directories), or whatever the default may have been.

You shouldn't need to be root to do this.

  • 1
    Not only you shouldn't need to be root to do this, but if you try to fix it using a recursive chmod as root, you will screw things up far worse than they are now. :) – Wildcard Aug 1 '16 at 23:51

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.