4

I am using Debian 8 stretch and I typed the command:

chmod  a-wx * 

Then my desktop turns black and I cannot reboot back to the OS.

4
  • Were you running this command as a root user, or with sudo? What directory did you run it in? I'm guessing only your user's home?
    – Xen2050
    Jan 3, 2019 at 0:59
  • Yes I think I ran it in the folder containing home Jan 3, 2019 at 5:18
  • That's a lot easier to fix then, I'll try an answer
    – Xen2050
    Jan 3, 2019 at 6:30
  • Welcome aboard. Although you got an answer here, I just wanted to make you (and others) aware of our sister site for questions about Unix & Linux
    – Mawg
    Jan 3, 2019 at 7:23

3 Answers 3

4

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)

0
1

Ctrl-alt and f1-f6 should work to get you into any other vtty.

From there your permissions can be restored by the root user.

0

I don't think it's possible, you may have to just salvage your files and re-install.

However, according to this post, you may try cutting all the files off your broken OS and pasting them back in. The permissions might not be copied and you might be able to boot back in. All of this would be done from a recovery OS of course.

And I would like to say my congratulations for bricking your system. That was quite a move.

2
  • Well fortunately I have nothing important in the OS as it happened the first day I download Debian Jan 3, 2019 at 5:20
  • In that case I would just reinstall to save you all the hassle. Jan 3, 2019 at 8:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .