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?
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
withsudo
).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 usesudo 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 appending2>/dev/null
to your command...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, typeThis command should return something like:
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 thesudo
command elevates your privileges and thus as thefind
command is now executed by the superuser the directory and its sub-directories can now be accessed.