Score:0

I accidentally ran sudo chmod -R 777 /home/

sa flag

I accidentally executed:

sudo chmod -R 777 /home/

Is there any way to recover from this?

vanadium avatar
cn flag
If you know how the permissions of some critical files need to be set, then yes. Better perhaps reset all user profiles and copy the user data back.
waltinator avatar
it flag
Please explain how you "accidently" ran a command. "Mistakenly" might be what you mean.
Score:8
in flag

Usually yes. You can change back to default permissions of 755 (directories) and 644 (files).

But you need to set permissions for some files, e.g. files in .ssh, .gnupg or .local/bin.

# Set all files to 664, and all directories to 755
sudo find /home -type f -exec chmod 644 {} +
sudo find /home -type d -exec chmod 755 {} +

# Optional, set individual /home/ directories to private
# as it is default for Ubuntu > 21.04
sudo chmod 750 /home/*/

# Restrict .ssh directory
if [ -d ~/.ssh ]; then
    chmod 700 ~/.ssh
    find ~/.ssh -type f -exec chmod 600 {} +
fi

# Restrict .gnupg directory
if [ -d ~/.gnupg ]; then
    chmod 700 ~/.gnupg
    find ~/.gnupg -type f -exec chmod 600 {} +
fi

# Restrict access to .Xauthority
[ -f ~/.Xauthority ] && chmod 600 ~/.Xauthority

# Give +x for all files in $PATH
echo "$PATH" | tr : '\0' | grep -z '^/home' | xargs -r -0 -I{} chmod +x {}/*
  • If you have more than one user, you can change permissions using sudo and /home/*/ instead of ~/.
  • Note, that if you manually changed permissions of some files, you need to set this again.
  • This might not be complete.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.