Permission Denied running find command

9,343

Looks like you have some folders with incorrect owners (or maybe permissions) in your home directory.

The Permission denied warning means that find could not search in a specific folder because it did not have the permissions to list its content, obviously.

In your home directory, the most likely cause is that you were running some GUI applications with sudo that messed up file ownerships. To fix this and make you the owner of all files in your home directory again, run this:

sudo chown -R $USER ~

Otherwise, if you are sure all permissions and ownerships are correct and you don't want to modify anything, you can also just hide the warning from the output by appending a STDERR redirection to /dev/null to your find command:

find . -name "*log*" -name "*2016*" 2> /dev/null
Share:
9,343

Related videos on Youtube

Cleber Holanda
Author by

Cleber Holanda

Linux User. Open Source lover. Microsoft Office Subscriber. I hate extremism

Updated on September 18, 2022

Comments

  • Cleber Holanda
    Cleber Holanda over 1 year

    I'm running this command:

    cleber@ubuntux:~$ find . -name "*log*" -name "*2016*"
    ./log-2016-05-04.txt
    ./log-2016-05-03.txt
    ./log-2016-05-08.txt
    ./log-2016-05-02.txt
    ./log-2016-05-05.txt
    find: ‘./.cache/dconf’: Permission denied
    ./log-2016-05-01.txt
    ./log-2016-05-06.txt
    ./log-2016-05-09.txt
    ./log-2016-05-07.txt
    ./log-2016-05-10.txt
    find: ‘./.dbus’: Permission denied
    

    Why am I getting the "Permission denied" error? All my permission setting on /home/cleber are set correctly. Someone can help me? Thank you.

    • Soren A
      Soren A over 7 years
      @George It's not a good idea to excursively change permissions in system generated folders. Many of them requires restricted rigths to function correctly.
    • Byte Commander
      Byte Commander over 7 years
      @George chmod 777 is like Vodka, first you think it solves all your problems, but soon you'll wake up with a massive headache. Avoid it.
    • George Udosen
      George Udosen over 7 years
      If he has issues in his / that's a different matter but in his /home directory it should be so. All files and folders there should be accessible to the owner [in this case Holanda].
    • George Udosen
      George Udosen over 7 years
      @ByteCmmander, yes I was using that as an example as to how to use -R option to set permissions deep in the folder not asking he use that. Holanda please take note.
    • Videonauth
      Videonauth over 7 years
      @George all files should be accessible and being owned by the home directory owner, this mean at least 644 for files and 755 for folders but even that is very broad setting, remember that the second digit is for group and the other is for ALL others, I personally wouldn't go for such a risk and simply 777 all files. Please look here for a refresher on permissions.
    • George Udosen
      George Udosen over 7 years
      @Videonauth, I didn't mean it literally was just for illustrations. Ok I will get rid of the comment, sorry guys.
    • Videonauth
      Videonauth over 7 years
      @George it wasn't for being mean to you, just think who all reads it, and there are already to many people out there who believe 777 is the norm setting :)
    • George Udosen
      George Udosen over 7 years
      @Videonauth, Yes I felt that way too that's why I got rid of it, lest some one uses it.
    • Cleber Holanda
      Cleber Holanda over 7 years
      Thank you guys @George now I clearly understand some files can't be owned by the user even located at /home/cleber
  • Porcupine
    Porcupine over 4 years
    Do all files and folders (including ~/.cache/dconf) in the home folder should be owned by the user (in a freshly installed operating system)?
  • Byte Commander
    Byte Commander over 4 years
    @Nikhil Yes, that's my understanding. I don't know of any exception so far.