16.04 - How To Grant Read Write Access To Folder / File after Messing Up

Folder : /usr/share/themes

I was trying to beautify my desktop so downloaded some themes. Found out that I don't have permission to paste the theme files to the above folder. So I used the guide here: Give user write access to folder

This has messed up the system theme & now the folder is inaccessible and the system has a white theme (which I presume means no theme). Running stat themes gives :

xx@TPX260:/usr/share$ stat themes
  File: 'themes'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d  Inode: 2228383     Links: 17
Access: (0666/drw-rw-rw-)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2016-10-18 09:38:10.786996316 +0100
Modify: 2016-10-18 09:33:18.320935727 +0100
Change: 2016-10-18 09:35:18.308242550 +0100
 Birth: -

How can I get permissions of the directory back to the OS default so that themes can start working again?


Solution 1:

It's not read/write permission causing your problem - directories need x permission to be accessed. That one should have mode 755, not 666

sudo chmod 755 /usr/share/themes

Check it looks like this:

$ ls -ld /usr/share/themes
drwxr-xr-x 43 root root 4096 Apr 20 23:13 /usr/share/themes

Check the permissions on the theme directories inside - they need to have 755 permissions as well

When you really need to add something to a system (root owned) directory, don't touch the file permissions at all - just use sudo to get elevated permissions for one command, for example:

sudo cp my_file /path/to/system/directory