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.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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 (
Or, you can try booting your main install in Single-user mode:
DEBIAN / UBUNTU root PASSWORD RECOVERY (with GRUB 2)
- First screen - grub - press e
- Modify kernel line: add
ro quietand at the end of this line add
- Press F10
- 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
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.
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.