3

can not delete file in /etc/pam.d directory with root user on centos7.7 system,please help work out this problem.

#rm -f /etc/pam.d/2.txt
rm: cannot remove ‘/etc/pam.d/2.txt’: Permission denied

directory and file permission as follow:

$ ls -ld /
drwxr-xr-x 21 root root 4096 Aug  3 19:29 /
$ ls -ld /etc
drwxr-xr-x 154 root root 12288 Aug  3 22:26 /etc
$ ls -ld /etc/pam.d/
drwxrwxrwx 2 root root 4096 Aug  3 22:26 /etc/pam.d/
$ ls -l /etc/pam.d/2.txt
-rwxrwxrwx 1 root root 0 Aug  3 19:37 /etc/pam.d/2.txt

But when i rename pam.d to pam.dd(mv pam.d pam.dd) ,it is can delete file under pam.dd,it's strange! selinux is not open,selinux content also removed,facl is not set

# ls -lZd /etc
drwxr-xr-x root root ?                                /etc
# ls -lZd /etc/pam.d
drwxrwxrwx root root ?                                /etc/pam.d
# ls -lZd /etc/pam.d/2.txt
-rwxrwxrwx root root ?                                /etc/pam.d/2.txt

both file and directory is mutable

# lsattr -d /etc/pam.d
---------------- /etc/pam.d

# lsattr /etc/pam.d/2.txt
---------------- /etc/pam.d/2.txt
4
  • File is immutable ? Try lsattr /etc/pam.d/2.txt
    – steve
    Aug 3 at 17:01
  • both file and directory is mutable ``` # lsattr -d /etc/pam.d ---------------- /etc/pam.d # lsattr /etc/pam.d/2.txt ---------------- /etc/pam.d/2.txt ```
    – 谭应科
    Aug 3 at 17:06
  • Anything in the kernel log? Aug 4 at 9:01
  • Nothing in messages log
    – 谭应科
    Aug 4 at 15:21

Your Answer

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

Browse other questions tagged or ask your own question.