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

- 32,861
- 27
- 118
- 178
2 Answers
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

- 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 aredr-x------ $USER $USER
. Root has no permissions to read this directory, so withsudo
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
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.

- 131
ls -ld /tmp
andls -ld /home
– Sergiy Kolodyazhnyy Jan 23 '16 at 15:02/home/$USER
is owned by the$USER
, it means root doesn't own that. Everything in/
folder is root owned but not everything in subfolders is root owned – Sergiy Kolodyazhnyy Jan 23 '16 at 15:04/tmp
and that file is owned by you – Sergiy Kolodyazhnyy Jan 23 '16 at 15:05/var/spool/cron/crontabs/
, and some files related to the display manager – steeldriver Jan 23 '16 at 15:07/home
, thus the owner of that top directory can remove subdirectories . However, nonetheless permissions of that folder stand as$USER:$USER
. – Sergiy Kolodyazhnyy Jan 23 '16 at 15:19