I’m using Centos 8.0 and my kernel version:
4.18.0-147.5.1.x86_64
Backgroud:
The messages on my host not rotated for a long time,and when I use "logrotate -v -f" to force rotating messages, it shows "rename messages: Operation not permitted".So I try renaming the messages immediately.
-rw------- 1 root 15464299992 Jul 15 10:12 messages
-rw------- 1 root 11644353 Sep 7 2020 messages-20200907.gz
-rw------- 1 root 8834073 Sep 13 2020 messages-20200913.gz
renaming /var/log/messages to /var/log/messages-20210715
error: failed to rename /var/log/messages to /var/log/messages-20210715: Operation not permitted
Here is my operation and the terminal’s output:
[root@node-5 log]# mv messages messages-20210715
mv: cannot move ‘messages’ to ‘messages-20210715’: Operation not permitted
[root@node-5 ~]# whoami
root
I login as root,why do I still come across such problem? How can I solve this?
2
Answers
@DavidC.Rankin Thx for replying.Here is the
ls -ald .
for messages:So I don't think this may be a problem about permissions. I also used
strace
to follow the syscall:Unfortunately,there are too many branches in function
do_renameat2
so I haven't found the exact exit yet.The problem got solved:
Show the file attributes with
lsattr
, it seems that messages got an attribute ‘a’,so it can’t be renamed.And with command
chattr -a messages
,messages can be renamed again.