Ubuntu – Permissions messed up in home folder

16.04chmodchownpermissions

Despite the fact that I didn't run any chmod or chown commands, I seemed to have lost the ability to cd into some folders in my home directory.
So I ran according to various answers on this forum since I have no clue about linux permissions:

sudo chmod -R 666 /home/rasmus/
sudo chown -c rasmus /home/rasmus/
sudo chown rasmus:rasmus /home/rasmus/
chmod 750 /home/rasmus/
sudo chown -R rasmus:rasmus /home/rasmus/
sudo chmod a+rx /home
sudo chmod u+w /home

leaving my home dir in this state:

10:57:35: 8𝌆𝌆𝌆D:[~] ls -l
total 52
drw-rw-rw- 2 rasmus rasmus 4096 Apr 15 10:43 catkin_ws/
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 16:31 Desktop/
drw-rw-rw- 3 rasmus rasmus 4096 Apr 15 09:31 Documents/
drw-rw-rw- 4 rasmus rasmus 4096 Apr 14 14:55 dotfiles/
drw-rw-rw- 3 rasmus rasmus 4096 Apr 14 15:27 Downloads/
-rw-rw-rw- 1 rasmus rasmus 8980 Apr 14 14:03 examples.desktop
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 16:31 Music/
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 16:31 Pictures/
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 16:31 Public/
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 16:31 Templates/
drw-rw-rw- 2 rasmus rasmus 4096 Apr 14 14:22 Videos/

Apparently, I can read the folders, but not cd into them:

10:58:54: 8𝌆𝌆𝌆D:[~] ls Desktop/
10:58:58: 8𝌆𝌆𝌆D:[~] cd Desktop/
bash: cd: Desktop/: Permission denied

What do I need to do to fix this?

Best Answer

  • Don't know where the command

    sudo chmod -R 666 /home/rasmus/
    

    is from. But that one pretty bad. It removes the executable bit on all folderes which is needed to list a directory or change to that directory. Furthermore, you gave read/write access on each file in your home directory to anyone. You maybe also want to fix that.

    Since all your files and directories have 666 access rights, you could restore the directory setting as follows.

    sudo find /home/rasmus -type d -exec chmod 755 "{}" \;
    
  • Related Question