0

Root does not own the /home/* folders, but what other folders does root not own?

Tim
  • 32,861
  • 27
  • 118
  • 178

2 Answers2

3

If your purpose is to find all files and directories accessible by you, use find utility with -group flag.

 sudo find / -group $USER  | less 

If you want to filter out only directories, use -type flag

 sudo find / -type d -group $USER  | less 

More info in man find. Ownership of files found might belong to root, but if a file belongs to your group, as well as has read permissions for your group, you can access those files

To find files owned by you , use -user flag

find / -user $USER -ls | less

On a side note, you may want to search without sudo, because if a file is owned by you but not readable by others, it may throw error for sudo

To avoid errors in the output, use 2>/dev/null redirection. Like so

find / -user $USER -ls 2> /dev/null | less
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • I'm not sure I agree with the "search without sudo" remark: isn't it much more common to have a directory that's only traversable by root containing files belonging to the user(s), than the other way around? – steeldriver Jan 23 '16 at 15:27
  • 1
    @steeldriver consider the directory /run/user/1000/gvfs . With sudo it throws an error , because the permissions are dr-x------ $USER $USER . Root has no permissions to read this directory, so with sudo it will throw an error. But if I search as user, I can read it, and find therefore will list it. But it's just a suggestion, not a practice that I 100% endorse. Users must exercise their own judgement , I suppose – Sergiy Kolodyazhnyy Jan 23 '16 at 15:33
2

Apart from user folders that aren't root, everything it root owned. That's why you should only use su or sudo if you need to, because you can really mess things up.