0

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

Tim
  • 32,274
  • 27
  • 118
  • 177
  • Tim , you could easily check that with `ls -ld /tmp` and `ls -ld /home` – Sergiy Kolodyazhnyy Jan 23 '16 at 15:02
  • @Serg I'm kinda asking if there are others is doesn't own? E.g. is there a random folder in /var I own? – Tim Jan 23 '16 at 15:03
  • Considering that `/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
  • When you download a pdf file and tell firefox to just open it, it goes into `/tmp` and that file is owned by you – Sergiy Kolodyazhnyy Jan 23 '16 at 15:05
  • ... also things like your own crontab (if you have one) in `/var/spool/cron/crontabs/`, and some files related to the display manager – steeldriver Jan 23 '16 at 15:07
  • "root" owns everything. You can claim /home/ is owned by the user but "root" is able to delete it without any restrictions and therefor also owns it. – Rinzwind Jan 23 '16 at 15:17
  • @Rinzwind technically yes, because user's home directory is a subdirectory of `/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
  • Still the answer to the title is: nothing. – Rinzwind Jan 23 '16 at 15:31
  • 1
    Possible duplicate of [What if I accidentally run command "chmod -R" on system directories (/, /etc, ...)](http://askubuntu.com/questions/43621/what-if-i-accidentally-run-command-chmod-r-on-system-directories-etc) – bain Jan 24 '16 at 21:03
  • @bain no. i'm just interested... – Tim Jan 24 '16 at 21:04

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
  • 103,293
  • 19
  • 273
  • 492
  • 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.