0

I have very strange issue

when we perform the following ( change owner from bash script ) on our redhat machine

chmod 600 /etc/yum.repos.d/*.repo

we get:

chmod: cannot access ‘/etc/yum.repos.d/pgdg-94-redhat.repo’: No such file or directory
chmod: cannot access ‘/etc/yum.repos.d/pgdg-94-redhat.repo’: No such file or directory
chmod: cannot access ‘/etc/yum.repos.d/pgdg-94-redhat.repo’: No such file or directory
chmod: cannot access ‘/etc/yum.repos.d/pgdg-94-redhat.repo’: No such file or directory
chmod: cannot access ‘/etc/yum.repos.d/pgdg-94-redhat.repo’: No such file or directory

but file exsist under /etc/yum.repo.d

yum.repos.d]# ls -ltr 

-rw-------. 1 root root 482 Mar 29 2016 pgdg-94-redhat.repo

so how it can be - what is going here ?

  • Use chown to change ownership, chmod to change permissions. Are the files that you trying to run chmod on actually symbolic links, and if so, do they link to existing files? – Kusalananda Aug 24 '17 at 19:06
2

As Hauke mentioned, SELinux is likely the issue. Are you trying to change the permissions to a different user/mode? ls -lZ will give you the file with the particular selinux context.

An example would be:

rw-r--r--. root root system_u:object_r:etc_t:s0       rhel-source.repo

if the context isn't right, it won't work.
in this case, # restorecon /etc/yum.repos.d/* will fix the contexts.

As far as your script goes, at the end, you should probably do the restorecon command on the /etc/yum.repos.d directory to ensure the contexts on the repo files are correct. The OS will then work with them.

0

The dot at the end of -rw-------. shows that there is an SELinux security context for this file. And given the result it probably blocks the access.

  • so how we can avoid this error? – yael Aug 24 '17 at 19:15
  • @yael You have to reconfigure SELinux. But I am not familiar with it so I cannot tell you how to do that. You might ask a new question here. One obvious question is: Who configured that? Maybe that is a default configuration. – Hauke Laging Aug 24 '17 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.