What to do when you remove permission for all users with chmod?

Since you only removed write & execute permission for files in your home directory, and it looks like there's no recursive option, so none of the contents of sub directories were affected, but you probably can't cd into the directories anymore which is probably causing problems.

You should be able to add those permissions back, and there's a few options to do that:

  • If you've got a live USB / DVD handy, just boot it then mount your main install's home partition with write access (rw).

  • Or, you can try booting your main install in Single-user mode:

    DEBIAN / UBUNTU root PASSWORD RECOVERY (with GRUB 2)

    1. First screen - grub - press e
    2. Modify kernel line: add single between ro quiet and at the end of this line add init=/bin/bash
    3. Press F10
    4. When the prompt is root@(none):/# you have to remount the / partition to have read-write access: mount / -rw -o remount

Now that you've got access to your user's home (it's a good time to backup any important files, just in case) cd to your user's home folder and just run a "reverse":

    chmod -v a+wx *

That should add back write permissions & let you cd into directories again, and hopefully boot OK.

It'll also add execute permission for regular files in your home directory, which isn't perfect but shouldn't cause any problems either. You could remove execute permission from non-hidden files with a GUI file manager, or something like

    find [home folder] -maxdepth 1 -type f  \! -name ".*" -print0 | xargs -0 chmod -v a-x

Another option is to just replace everything in your home with "defaults" from /etc/skel then the next boot should be like the very first boot.


Or yet another option would be to just create a new user (while booted in single-user mode) using adduser, and forget about or delete the whole old user (with deluser)

Tags:

Debian

Chmod