Chown permission denied on owned dir

41,835

Solution 1

The directories need x permission to open. You can probably do,

chmod 755 bad_dir and then try your chown command.

According to here, the dot at end means,

According to ls.c (line 3785), . means an SELinux ACL. (+ means a general ACL.)

If it is SELinux messing, use setenforce to modify its mode. Run setenforce 0 to put SELinux in permissive mode and setenforce 1 to put it back into enforcing mode.

Solution 2

I made a stupid mistake. We had few machines provisioned identically, but one (with this problem) was changed by one of my colleagues.

The bad_dir was mounted NFS, which explains all problems. Thanks to Joel Davis which suggest me to check this again I solved my issue.

Share:
41,835

Related videos on Youtube

Piotr Stapp
Author by

Piotr Stapp

Updated on September 18, 2022

Comments

  • Piotr Stapp
    Piotr Stapp almost 2 years

    I have following directory (/usr/local)

    rwxr-xr-x. 43 root root  4096 Jul 25 14:19 .
    rwxr-xr-x. 14 root root  4096 Feb 21 10:27 ..
    rwxr-xr-x.  2 root root  4096 Jun 28  2011 bin
    [...]
    rwxr-xr-x   1 root root  8192 Jul 25 13:41 bad_dir
    rwxr-xr-x.  4 root root  4096 Mar 28 11:56 good_dir
    

    I am logged as root. When I run chown root:root good_dir everything is ok, but when I run chown root:root bad_dir I got chown: changing ownership of '/usr/local/bad_dir': Permission denied

    What is wrong with bad_dir? What should I change to make chown working correctly? I see a dot in the end of permissions, but I don't know what does it mean.

    Update

    Running

    echo 0 > /selinux/enforce
    chmod 755 bad_dir
    

    gives also chmod: changing permissions of 'bad_dir': Permission denied

    Update 2

    Output of ls -la /usr is

    total 128
    drwxr-xr-x.  14 root root  4096 Feb 21 10:27 .
    dr-xr-xr-x.  24 root root  4096 May 28 08:22 ..
    dr-xr-xr-x.   2 root root 28672 Jun 27 10:29 bin
    drwxr-xr-x.   2 root root  4096 Jun 28  2011 etc
    drwxr-xr-x.   2 root root  4096 Jun 28  2011 games
    drwxr-xr-x.  36 root root  4096 Jul 23 14:04 include
    dr-xr-xr-x.  12 root root  4096 Apr 11 17:10 lib
    dr-xr-xr-x.  45 root root 36864 Jul 23 14:04 lib64
    drwxr-xr-x.  14 root root  4096 Mar 28 11:58 libexec
    drwxr-xr-x.  43 root root  4096 Jul 25 14:34 local
    drwxr-xr-x.   3 root root  4096 Feb 21 10:27 man
    dr-xr-xr-x.   2 root root 12288 Jul 23 14:04 sbin
    drwxr-xr-x. 106 root root  4096 Mar 28 12:00 share
    drwxr-xr-x.   4 root root  4096 Nov 20  2013 src
    lrwxrwxrwx.   1 root root    10 Nov 20  2013 tmp -> ../var/tmp
    
    • Admin
      Admin almost 10 years
    • Admin
      Admin almost 10 years
      @Ramesh Added to question
    • Admin
      Admin almost 10 years
      @Garath, thanks. Also, could you please tell the output of ls -la /usr/local?
    • Admin
      Admin almost 10 years
      @Ramesh it is in the top of the question (the first one)
    • Admin
      Admin almost 10 years
      Please include the output of lsattr /-d usr/local/bad_dir
    • Admin
      Admin almost 10 years
      @CristianCiupitu I got: lsattr: Inappropriate ioctl for device While reading flags
    • Admin
      Admin almost 10 years
      Is this on an NFS mount or anything like that?
    • Admin
      Admin almost 10 years
      @JoelDavis no it isn't
    • Admin
      Admin almost 10 years
      stat --format='%D' /usr/local /usr/local/bad_dir
    • Admin
      Admin almost 10 years
      shorter version of the above would be df -hP /usr/local/bad_dir
  • Piotr Stapp
    Piotr Stapp almost 10 years
    When I run chmod 755 bad_dir I got chmod: changing permissions of 'bad_dir': Permission denied
  • Ramesh
    Ramesh almost 10 years
    @Garath, you should disable your selinux temporarily and then try. See my updated answer.
  • Piotr Stapp
    Piotr Stapp almost 10 years
    I doesnt' work. See my update
  • minorcaseDev
    minorcaseDev almost 10 years
    @Garath: What's the output of command getenforce? Please run setenforce 0 and not echo 0 > /selinux/enforce.
  • ludiegu
    ludiegu almost 10 years
    Could you do a getfacl bad_dir ? Maybe it's just an ACL to fix :)