1

When I type a command like find / -name ??.conf the output includes a lot of directories such as:

find : /home/simmer/.local/share/gvfs-metadata : Permission Denied 

I don't get the desired result.

But if I use the same command with sudo

sudo find : /home/simmer/.local/share/gvfs-metadata

Then it shows the expected result.

Why do I need sudo privileges for this?

2 Answers 2

1

You shouldn't be getting that error, as the directory should be owned by you. I guess you have been running graphical applications with sudo.

While logged in as yourself, correct the ownership (please always be careful when using chown with sudo).

sudo chown -R $USER: ~/.local/share/gvfs-metadata

Now you will not need sudo to search this directory.

In general, permission errors with find occur because you don't have read permission on the directory, which is the case for many system directories owned by root. You can use sudo find (be very careful before adding and actions to the command) or if you don't want to search as root, just discard the errors to de-clutter results by appending 2>/dev/null to your command...

find /some/path -some_test some_condition 2>/dev/null
1

If the find command is executed by a non-superuser it will not be able to access files and directories that are not owned by the user or if the permissions "r,w,x" have not be granted to that user. If you want to check this, type

ls -l /home/simmer/.local/share/gvfs-metadata

This command should return something like:

drwx------  2 simmer simmer 12288 Jun  8 17:39 gvfs-metadata

The first column represents the permissions set by the owners of the file or directory. The third and fourth columns represent the owner and group of the file/folder respectively.

If you are not the owner or if you do not have sufficient permission as indicated by the first column, the find program cannot access them. However, using the sudo command elevates your privileges and thus as the find command is now executed by the superuser the directory and its sub-directories can now be accessed.

3
  • Also as @Zanna mentioned you should not be getting that error. It should be owned by you Jun 7, 2017 at 18:28
  • @Zanna I've only started to write answers on stack-exchange and so I'm not very familiar with the etiquette. Thanks for the advice. Jun 8, 2017 at 12:21
  • :) thanks for editing. Looks great now. Welcome to Ask Ubuntu & Stack Exchange
    – Zanna
    Jun 8, 2017 at 12:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .